///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18, cs;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

        cin>>n;
        sl st;
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
            st.insert(arr[i]);
        }
        while(st.size()>1)
        {
               auto it1=st.begin();
               auto it2=st.end();
               it2--;
               a=*it1;
               b=*it2;
               x=b-a;
               st.erase(b);
               st.insert(x);
        }
        auto it=st.begin();
        cout<<(*it)<<endl;




    //code
    return 0;
}



#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
	return b==0?a:gcd(b,a%b);
}
int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans << endl;
}