def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    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 = sum(a)
        print(ans)
        
if __name__ == '__main__':
    main()