from sys import stdin
input()
a=map(int,stdin.readline().rstrip().split())
b=int(input())
for i in range(b):
  n,m=map(int,stdin.readline().rstrip().split())
  a=[m if i==n else i for i in a]
  print(sum(a))