import numpy as np
def stupid():
    N=input()
    N=int(N)
    A=input()
    A=A.split(" ")
    A=[int(i) for i in A]
    A=np.array(A,dtype=np.uint64)
    Q=input()
    Q=int(Q)
    BC=np.empty((Q,2))
    for i in range(Q):
        buf=input().split(" ")
        buf=[int(i) for i in buf]
        BC[i]=buf
    for i in range(Q):
        A[BC[i][0]==A]=BC[i][1]
        print(np.sum(A))

if __name__ == "__main__":
    stupid()