n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

for gyou in range(q):
	a=[bc[gyou][1] if i==bc[gyou][0] else i for i in a]
	print(sum(a))
