N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for n in range(Q):
    A = [C[n] if i == B[n] else i for i in A]
    print(sum(A))
