N = int(input())
a = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]
S = [0]*Q

for i, bc in enumerate(BC):
  b = bc[0]
  c = bc[1]
  a = [c if i == b else i for i in a]
  S[i] = sum(a)

[print(i) for i in S]