import copy

n = (int)(input())
a = list(map(int, input().split()))
q = (int)(input())
b = []
c = []
for i in range(q):
    _b, _c, = map(int, input().split())
    b.append(_b)
    c.append(_c)

#print("{}".format(b))
#print("{}".format(c))

for i in range(q):
    _a = [c[i] if j == b[i] else j for j in a]
    #print("_a = {}".format(_a))
    a = copy.copy(_a)
    print("{}".format(sum(a)))