n = input()
a = list(map(int, input().split()))
q =int(input())
s = 0
for i in range(q):
  b,c = map(int, input().split())
  numb = a.count(b)
  if numb > 0:
    for b in a[:]: a.remove(b)
  s = sum(a) + c * numb +s
  print(s)