a=input()
b=input().split(" ")
c=input()
d=int(c)
point1=[]
for i in range(d):
    a=input().split(" ")
    point1.append(a)
point=[int(i for i in point1)]
for i in range(d):
    if i in point[i][0]:
        b[i]=point[i][1]
        print(sum(point))
    else:
        print(sum(point))
    





    