n=int(input())
a = list(map(int, input().split()))
q=int(input())

b=[0] * q
c=[0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

# print("end")
for k in range(q):
    
    rep = [c[k] if i == b[k] else i for i in a]
    # print(rep)
    a = rep
    res = sum(rep)
    print(res)