import sys
from collections import deque
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    q = I()
    s = deque()
    for rep in range(q):
        b,c = IL()
        tmp = 0
        for item in a:
          if item==b:
            tmp += c
          else:
            tmp += item
        s.append(tmp)
    for _ in range(q):
        print(s.popleft())
    return

if __name__=='__main__':
    Main()