N = int(input())
p = input().split()
p_int = [int(n) for n in p]
Q = int(input())
for i in range(Q):
  B, C = map(int, input().split())
  p_int = [C if i == B else i for i in p_int]
  print(sum(p_int))