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