n = input()
a = list(map(int, input().split()))
q =int(input())
listb = []
listc = []
listnumcon = []
rest = 0
numcon = 0
for i in range(q):
  b,c = map(int, input().split())
  listb.append(b)
  listc.append(c)
  numb = a.count(b)
  listnumcon.append(numb)
  if numb > 0:
    for i in a[:]:
      if i == b :
        a.remove(b)
  for j in listc:
    if j == b:
      numcon += listnumcon[listc.index(j)]
  sumresta = sum(a)
  s = sumresta + (c * (numb+numcon)) + rest
  rest = s - sumresta -rest
  numcon = 0
  print(s)