#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;

inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9')
	{
		if(s=='-') f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=x*10+s-48;
		s=getchar();
	}
	return f*x;
}

int gcd(int a,int b)
{
	return !b?a:gcd(b,a%b);
}

int main()
{
	int n=read();
	int ans=read();
	for(int i=2;i<=n;i++)
	{
		int a=read();
		ans=gcd(ans,a);
	}
	printf("%d\n",ans);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll l=-LINF,r=LINF,m=0;
ll f(ll x){
    if(x<=l){
        return l+m;
    }else if(x>=r){
        return r+m;
    }else{
        return x+m;
    }
}

int main(){
    int n;
    cin>>n;
    vi a(n),b(n);
    REP(i,n){
        cin>>a[i]>>b[i];
        if(b[i]==1){
            m+=a[i];
        }else if(b[i]==2){
            chmax(l,a[i]-m);
            chmax(r,l);
        }else{
            chmin(r,a[i]-m);
            chmin(l,r);
        }
    }
    int q;
    cin>>q;
    REP(i,q){
        ll x;
        cin>>x;
        cout<<f(x)<<endl;
    }

    return 0;
}