import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
Q=int(input())
B=[0]*Q;C=[0]*Q
for i in range(Q):
  B[i],C[i]=map(int,input().split())
#print(A)
D=[0]*10**5;W=[0]*10**5
for i in range(10**5):
  D[i]=A.count(i+1)
  W[i]=i+1

for i in range(Q):
    D[C[i]-1]+=D[B[i]-1]
    D[B[i]-1]=0
    print(int(np.average(D, weights=W)*10**5*(10**5+1)//2))