#include<iostream>
using namespace std;
int main(){
  int n1,n2,i,a[99];
  cin>>n1;
  for(i=0;i<n;i++) cin>>a[i];
  cin>>n2;
  for(i=0;i<n2;i++){
    int x,y,tong=0;
    cin>>x>>y;
    for(int j=0;j<n1;j++){
      if(a[i]==x) {a[i]=y; tong+=y;}
      else tong+=a[i];
    }
  }
}