import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
Q = int(input())

bc = np.array([list(map(int, input().split())) for i in range(Q)])

for i in range(Q):
    A[np.where(A == bc[i][0])] = bc[i][1]
    print(sum(A))