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