N = int(input())
a = input().split()
a = [int(i) for i in a]
ans_list = []
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    a = [C if i == B else i for i in a]
    ans_list.append(sum(a))
for i in ans_list:
    print(i)