def sol():
    n=int(input())
    A=[int(i)for i in input().split()]
    q=int(input())
    for i in range(q):
        b,c=map(int,input().split())
        if(b in A):
            p=A.index(b)
            A[p]=c
        print(sum(A))
if(__name__=='__main__'):
    sol()
