N=int(input())
List=list(map(int,input().split()))
Q=int(input())
sum=0
Number=[]
Alphabet=[]
for i in range(Q):
    n,a=input().split()
    Number.append(int(n))
    Alphabet.append(int(a))
for i in range(N):
    sum+=List[i]
for i in range(Q):
    sum+=(List.count(Number[i]))*(Alphabet[i]-Number[i])
    print(sum)