n = int(input())

a_list = list(map(int, input().split()))

q = int(input())

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