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 j in range(Q):
    rep = [i for i in A if i != B[j]]
    for _ in range(len(A) - len(rep)):
        rep.append(C[j])
    A = rep[::]

    print(sum(A))
