#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int n;
int a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    int g = a[0];
    for (int i=0; i<n; i++) {
	g = __gcd(g, a[i]);
    }

    cout<<g<<endl;
    
    
    return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#define sz(x) ((int)(x).size())
#define mp make_pair
#define full(a) a.begin(), a.end()
#define pii pair<int, int>
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 3e5 + 5;

// printf("%.2f\n", value); digits after decimal
// 'a' - 97
// 'A' - 65



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    int n; cin >> n;
    map<int, int> mmp;
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        mmp[a]++;
    }
    while (sz(mmp) > 1)
    {
        pii p = *mmp.rbegin();
        int X = p.first, c = p.second;
        p = *mmp.begin();
        int x = p.first;
        mmp.erase(prev(mmp.end()));
        mmp[X - x] += c;
    }
    cout << mmp.begin() -> first;
    return 0;
}