import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a_li = list(map(int, input().split()))
    q = int(input())

    ans_li = []

    for _ in range(q):
        b, c = map(int, input().split())
        a_li = [c if i == b else i for i in a_li]
        ans_li.append(sum(a_li))

    for s in ans_li:
        print(s)

if __name__ == '__main__':
    main()
