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

num = []

res = 0

for i in range(Q):
    for n in range(N):
        if A[n] == B[i][0]:
            num.append(B[i][1])
        else:
            num.append(A[n])
    A.clear()
    for l in num:
        A.append(l)
    num.clear()
    for m in range(N):
        res += A[m] 
    print(res)
    res = 0

