n = int(input())
lst = list(map(int, input().split()))
q = int(input())
lst_c = lst.copy()
for i in range(q):
    b, c = map(int, input().split())
    lst_c = [c if i == b else i for i in lst_c.copy()]
    print(sum(lst_c))