n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = []
for i in range(q):
    b,c = map(int, input().split())
    a = [c if i == b else i for i in a]
    ans.append(sum(a))
for i in ans:
    print(i)