N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

for i in range(Q):
    p, n = BC[i][0], BC[i][1]
    A = [x if x != p else n for x in A]
    print(sum(A))