N=int(input())
A=list(map(int,input().split()))
Q=int(input())
Gokei=[]

for _ in range(Q):
    B,C=map(int,input().split())
    A=[C if i==B else i for i in A]
    Gokei.append(sum(A))

for i in range(Q):
    print(Gokei[i])
    i+=1