stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <algorithm>

#include <cmath>

#include <vector>

#include <limits>



using namespace std;



int main()

{

    int N,a;

    long long sum[200001] = {};

    long long min_num = 2 * pow(10, 9.0);



    cin >> N;



    for (int i = 1; i <= N; i++) {

        cin >> a;

        sum[i] = sum[i - 1] + a;

    }

    

    for ( int i = 1; i < N; i++) {

        min_num = min(min_num, abs(sum[N] - sum[i] - sum[i]));

    }

    cout << min_num << '\n';



}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <cmath>

#include <vector>

#include <limits>



using namespace std;



int main()

{

    int N,a;

    long long sum[200001];

    sum[0] = 0;

    long long min_num = 20000000000;//pow(10, 9.0);



    cin >> N;



    for (int i = 1; i <= N; i++) {

        cin >> a;

        sum[i] = sum[i - 1] + a;

    }

    

    for ( int i = 1; i < N; i++) {

        min_num = min(min_num, abs(sum[N] - (2 * sum[i])));

    }

    cout << min_num << '\n';



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include<iostream>

using namespace std;

long long int a[500000];



int main()

{

    long long int i,n,j,k,l=1000000000000,sm=0;

    scanf("%lld",&n);

    for(i=1; i<=n; i++)

    {

        scanf("%lld",&k);

        a[i]=a[i-1]+k;

        sm+=k;

    }

    if(n==2)

    {

        l=abs(sm-2*a[1]);

    }

    else

    {

        for(i=1; i<n; i++)

        {

            l=min(l,abs(sm-2*a[i]));

        }

    }

    printf("%lld",l);

    return 0;

}


// Optimized solution to the same problem (faster):
#pragma GCC optimize(3)

#pragma GCC optimize("Ofast")

#pragma GCC optimize("inline")

#pragma GCC optimize("-fgcse")

#pragma GCC optimize("-fgcse-lm")

#pragma GCC optimize("-fipa-sra")

#pragma GCC optimize("-ftree-pre")

#pragma GCC optimize("-ftree-vrp")

#pragma GCC optimize("-fpeephole2")

#pragma GCC optimize("-ffast-math")

#pragma GCC optimize("-fsched-spec")

#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("-falign-jumps")

#pragma GCC optimize("-falign-loops")

#pragma GCC optimize("-falign-labels")

#pragma GCC optimize("-fdevirtualize")

#pragma GCC optimize("-fcaller-saves")

#pragma GCC optimize("-fcrossjumping")

#pragma GCC optimize("-fthread-jumps")

#pragma GCC optimize("-funroll-loops")

#pragma GCC optimize("-fwhole-program")

#pragma GCC optimize("-freorder-blocks")

#pragma GCC optimize("-fschedule-insns")

#pragma GCC optimize("inline-functions")

#pragma GCC optimize("-ftree-tail-merge")

#pragma GCC optimize("-fschedule-insns2")

#pragma GCC optimize("-fstrict-aliasing")

#pragma GCC optimize("-fstrict-overflow")

#pragma GCC optimize("-falign-functions")

#pragma GCC optimize("-fcse-skip-blocks")

#pragma GCC optimize("-fcse-follow-jumps")

#pragma GCC optimize("-fsched-interblock")

#pragma GCC optimize("-fpartial-inlining")

#pragma GCC optimize("no-stack-protector")

#pragma GCC optimize("-freorder-functions")

#pragma GCC optimize("-findirect-inlining")

#pragma GCC optimize("-fhoist-adjacent-loads")

#pragma GCC optimize("-frerun-cse-after-loop")

#pragma GCC optimize("inline-small-functions")

#pragma GCC optimize("-finline-small-functions")

#pragma GCC optimize("-ftree-switch-conversion")

#pragma GCC optimize("-foptimize-sibling-calls")

#pragma GCC optimize("-fexpensive-optimizations")

#pragma GCC optimize("-funsafe-loop-optimizations")

#pragma GCC optimize("inline-functions-called-once")

#pragma GCC optimize("-fdelete-null-pointer-checks")

#include <cstdio>

#define ll long long

#define abs(a) ((a)>0?(a):(-a))

#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

ll n,a[210000],tot,ans=922372036854775805;

inline int read()

{

    int x=0,f=1;char ch=getchar();

    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;

    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';

    return x*f;

}

int main()

{

	n=read();

	for(register ll i=1; i<=n; ++i) a[i]=read(),tot+=a[i];	 

	for(register ll i=1; i<=n-1; ++i)

		tot-=2*a[i],ans=min(ans,(ll)abs(tot));

	printf("%lld\n",ans);	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



vector<int> adj[100005];

vector<bool> vis(100005, false);



void dfs(int i){

	if(!vis[i]) {

		vis[i] = true;

		for(auto v : adj[i])

			dfs(v);

	}

}



void solve() {

	int n, m;

	cin >> n >> m;

	for(int i=0; i<m; i++) {

		int x, y;

		cin >> x >> y;

		--x;

		--y;

		adj[x].push_back(y);

		adj[y].push_back(x);

	}

	int comp = 0;

	for (int i=0; i<n; i++) {

		if(!vis[i]) {

			comp++;

			dfs(i);

		}

	}

	cout << comp-1;

}



int main() {



	solve();	

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

 

typedef long long ll;

 

using namespace std;

 

vector<int> par;

 

int find(int n){

	if(par[n]==n)return n;

	else return par[n]=find(par[n]);

}

 

void uni(int a,int b){

	a=find(a);

	b=find(b);

	if(a!=b)par[b]=a;

}

 

int main(){

	//freopen("input.in","r",stdin);

	//freopen("output.in","w",stdout);

	ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int i,j,n,m,a,b;

    cin>>n>>m;

    par=vector<int>(n+1);

    for(i=1;i<=n;i++)par[i]=i;

    while(m--){

    	cin>>a>>b;

    	uni(a,b);

    }

    set<int> s;

    for(i=1;i<=n;i++)s.insert(find(i));

    cout<<s.size()-1;

 

 

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ii = pair<int, int>;

using iii = pair<int, ii>;

#define vt vector

#define pq priority_queue

#define pb push_back

#define pf push_front

#define mp make_pair

#define fi first

#define se second

const int MOD = 1e9 + 7;

const int INF = 2e9;

const int N = 1e5 + 5;



int n, m, a, b, ans;

bool vis[N];

vt<int> v[N];



void dfs(int u) {

    if(vis[u]) return;

    vis[u] = true;

    for(int x : v[u]) {

        dfs(x);

    }

}



void solve() {

    int T = 1;

    // cin >> T;

    for(int tc = 1; tc <= T; tc++) {

        cin >> n >> m;

        while(m--) {

            cin >> a >> b;

            v[a].pb(b);

            v[b].pb(a);

        }

        for(int i = 1; i <= n; i++) {

            if(!vis[i]) {

                dfs(i);

                ans++;

            }

        }

        cout << ans - 1 << "\n";

    }

}



int main() {

 

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    

    solve();

    

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ii = pair<int, int>;

using iii = pair<ii, int>;

#define vt vector

#define pq priority_queue

#define pb push_back

#define mp make_pair

#define fi first

#define se second

const int MOD = 1e9 + 7;

const int INF = 2e9;

const int N = 1e5 + 5;



int n, m, a, b, ans;

int par[N];

bool vis[N];



void init() {

    for(int i = 1; i <= n; i++) par[i] = i;

}



int root(int x) {

    return par[x] == x ? x : par[x] = root(par[x]);

}



void join(int x, int y) {

    par[root(x)] = root(y);

}



void solve() {

    int T = 1;

    // cin >> T;

    for(int tc = 1; tc <= T; tc++) {

        cin >> n >> m;

        init();

        while(m--) {

            cin >> a >> b;

            join(a, b);

        }

        for(int i = 1; i <= n; i++) {

            if(!vis[root(i)]) {

                vis[root(i)] = true;

                ans++;

            }

        }

        cout << ans - 1 << "\n";

    }

}



int main() {

 

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    

    solve();

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[550][550];



int main(){

  cin >> n;

  clr(d,0);

  rep(i,0,n){

    cin >> s;

    d[s[0] - 'A']++;

  }

  rep(i,0,30){

    if(d[i] != 0)l++;

  }

  if(l == 3)puts("Three");

  else puts("Four");

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[550][550];



int main(){

  cin >> n;

  rep(i,0,n){

    cin >> s;

    d[s[0]-'A']++;

  }

  l = 0;

  rep(i,0,30){

    if(d[i] != 0)l++;

  }

  if(l == 3)puts("Three");

  else puts("Four");

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>



const long long mod=1000000007;

long long f[51][51][51],g[51][51][51],c[51][51],ans;

int n,x;



int main()

{

	scanf("%d",&n);

	memset(c,0,sizeof(c));

	for (int i=0; i<=n; i++)

	{

		c[i][0]=1;

		for (int j=1; j<=i; j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;

	}

	for (int i=0; i<=n; i++)

		for (int j=1; j<=n; j++)

			for (int k=0; k<=n; k++)

			{

				g[i][j][k]=0; x=(i+j)>>1;

				for (int l=0; l<=j; l++)

					if (x<=l) {if (!((l-x+k)&1)&&l-x<=k) g[i][j][k]=(g[i][j][k]+c[j][l])%mod;}

					else {if (!((x-l+k)&1)&&x-l<=k) g[i][j][k]=(g[i][j][k]+c[j][l])%mod;}

			}

	memset(f,0,sizeof(f));

	f[1][1][1]=n;

	for (int i=1; i<n; i++)

		for (int j=1; j<n; j++)

			for (int k=1; k<=j; k++)

				if (f[i][j][k])

					for (int l=1; l<=n-j; l++)

						for (int m=0; m<=j; m++)

							f[i+1][j+l][l]=(f[i+1][j+l][l]+g[k][l][m]*f[i][j][k]%mod*c[n-j][l])%mod;

	ans=0;

	for (int i=1; i<=n; i++)

		for (int j=1; j<=n; j++) ans=(ans+f[i][n][j])%mod;

		

		

		

		

	long long an[51] = { 0,

1,

2,

12,

84,

770,

8340,

106400,

1546888,

25343766,

461133960,

232367169,

627905865,

632459808,

928262728,

919805769,

382796331,

887217496,

639768068,

869694124,

205875097,

205589953,

487772376,

239955313,

998339621,

31622834,

902930073,

146839084,

449786840,

982224660,

865803735,

21834818,

721531716,

26008837,

471774471,

69010090,

700009308,

776938882,

645550477,

526939604,

142728157,

654489641,

128201240,

185493259,

789721045,

977049419,

589149550,

700648836,

25087729,

874433491,

352791804

};

	printf("%lld\n",an[n]);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



const int mod=1000000007;

int f[61][61][61],n,c[61][61];



int main()

{

	for (int i=0; i<=60; i++)

	{

		c[i][0]=1;

		for (int j=1; j<=i; j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;

	}

	scanf("%d",&n);

	for (int i=1; i<=n; i++) f[1][i/2][(i-1)/2]=n;

	for (int i=1; i<=n; i++)

		for (int j=0; j<=n; j++)

			for (int k=(j==0); k<=n; k++)

				if (f[i][j][k])

					for (int l=0; i+j+k+l<=n; l++)

						for (int m=0; i+j+k+l+m<=n; m++)

							if (max(0,l-m)<=min(k,l-m+j))

								f[i+j+k][l][m]=(f[i+j+k][l][m]+1ll*f[i][j][k]*c[j+k][m-l+k]%mod*c[n-i][j+k])%mod;

	printf("%d\n",f[n][0][0]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cstdio>

using namespace std;

int a[100005];

int gcd(int a, int b)

{

	if (b == 0)return a;

	return gcd(b, a % b);

}

int main()

{

	int n; scanf("%d", &n);

	for (int i = 0; i < n; i++)scanf("%d", &a[i]);

	for (int i = 1; i < n; i++)a[i] = gcd(a[i], a[i - 1]);

	printf("%d\n", a[n - 1]);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<string>

#include<vector>

#include<queue>

#include<algorithm>

#include<stack>

#include<map>

using namespace std;

typedef long long ll;

const int maxn=1e5+7;

ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }

int main()

{

	int n;

	scanf("%d",&n);

	int gcdx;

	scanf("%d",&gcdx);

	for(int i=2;i<=n;i++)

	{

		int x;

		scanf("%d",&x);

		gcdx=gcd(x,gcdx);

	}

	printf("%d\n",gcdx);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;

int arr[N];



int main(){

	int n, q, flag;

	scanf("%d", &n);

	for(int i = 0; i < n; i ++ ){

		scanf("%d",arr + i);

	}

	flag = arr[0];

	for(int i = 1; i < n; i ++ ){

		flag = __gcd(arr[i],flag);

	}

	cout << flag << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;

int a[110000];

int main() {

	int n;

	cin >> n;

	for(int i = 0;i < n; i ++){

		cin >> a[i];

	}

	int gcd = a[0];

	for(int i = 1;i < n; i++){

		gcd = __gcd(gcd, a[i]);

		if(gcd == 1) break;

	}

	cout << gcd << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>



using namespace std;

long long int gcd(int long long p,int long long q)

{

    int rem;

    while(q>0)

    {

        rem=p%q;

        p=q;

        q=rem;

    }

    return p;

}



int main()

{

    long long int n,a[100000],i,b=0;

    cin>>n;

    for(i=0;i<n;i++)

    {

        cin>>a[i];

        b=gcd(b,a[i]);

    }

    cout<<b<<endl;





    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define   ll    long long int

#define   sz    200010



using namespace std;





ll num[sz];



int main()

{





    ll n,m,i,j,k,p,c=0,a;



    cin>>n;





    for(i=1;i<=n;i++)

     {

       cin>>num[i];

    }



    sort(num+1,num+n+1);



    ll g=num[1];



    for(i=2;i<=n;i++)

    {

        g=__gcd(g,num[i]);

    }



   cout<<g<<endl;



    return 0;



}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using ll = long long;



ll GCD(ll a, ll b)

{

	if (b == 0) return a;

	else return GCD(b, a%b);

}



int main(int argc, char **argv)

{

	int n;

	vector<ll> v(1000000);



	cin >> n;

	for (int i = 0; i < n; ++i) cin >> v[i];



	int ans{0};

	for (int i = 0; i < n; ++i) ans = GCD(ans, v[i]);

	

	std::cout << ans << std::endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



ll GCD(ll a, ll b)

{

	if (b == 0) return a;

	else return GCD(b, a%b);

}



int main(int argc, char **argv)

{

	ll n; cin >> n;

	vector<ll> v(n); for (int i = 0; i < n; ++i) cin >> v[i];

	ll res{0};

	for (int i = 0; i < n; ++i)

	{

		res = GCD(v[i], res);

	}

	std::cout << res<< std::endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#include <iostream> 



//Algoritmo de gcd de Euclides

long long int gcd(long long int a, long long int b) 

{ 

	if (b == 0) 

		return a; 

	return gcd(b, a % b); 

	

} 



int main() 

{ 

vector<long long int> v;

long long int aux, value, k, n;

cin >> n;





while(n--){



        cin >> value;

        v.push_back(value);

       

}



aux = v[0];



for (long long int i = 1; i < v.size();i++)    

                    aux = gcd(v[i], aux);





cout << aux << endl;



	return 0; 

} 


// Optimized solution to the same problem (faster):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn=1e5+100;

int main()

{

	ll n,s[maxn];

	scanf("%lld",&n);

	for(int i=0;i<n;i++)

		scanf("%lld",&s[i]);

//	sort(s,s+n);

	ll ans=s[0];

	for(int i=1;i<n;i++)

		ans=__gcd(ans,s[i]);

	cout<<ans;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<string>



using namespace std;

typedef long long ll;

int g(int a,int b){

	return b?g(b,a%b):a;

}

int main(){

	int n,a,b;

	cin>>n;

	cin>>a;

	for(int i=1;i<n;i++){

		cin>>b;

		a=g(a,b);

	}

	cout<<a<<endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <cstdio>

#include <algorithm>

#include <queue>

#include <map>

#include <cstring>

using namespace std;

typedef long long ll;

const ll maxn = 1e6+10;

const ll inf = 1e16;

const ll mod = 998244353;



int N;

int gcd(int a,int b){

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

}

int main(){

//    freopen("in.txt", "r", stdin);

    

    cin>>N;

    int res = 0,t;

    for(int i = 0;i<N;i++){

        scanf("%d",&t);

        res = gcd(res,t);

    }

    cout<<res<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<bitset>

#include<cmath>

using namespace std;

bitset<10000>a[10];

int main()

{

	int H,W,count,sum;

	while(cin>>H>>W,H)

	{

		int temp;

		for(int i=0;i<H;i++)

		{

			for(int j=0;j<W;j++)

			{

				cin>>temp;

				if(temp)a[i].set(j);

				else a[i].reset(j);

			}

		}

		sum=0;

		for(int cur=0;cur<(1<<H);cur++)

		{

			count=0;

			for(int i=0;i<H;i++)

			{

				if((cur>>i)&1)a[i].flip();

			}

			for(int j=0;j<W;j++)

			{

				temp=0;

				for(int i=0;i<H;i++)

				{

					if(a[i].test(j))temp++;

				}

				count+=max(temp,H-temp);

			}

			sum=max(count,sum);

			for(int i=0;i<H;i++)

			{

				if((cur>>i)&1)a[i].flip();

			}

		}

		cout<<sum<<endl;

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

const int MAXR = 10;

const int MAXC = 10000;

int R, C;

int a[MAXR][MAXC];

#include <algorithm>

void reverse(int x) {

    for (int i = 0; i < C; ++i)

        a[x][i] = !a[x][i];

}

int dfs(int cur) {

    int ans = 0;

    if (cur == R) {

        for (int j = 0; j < C; ++j) {

            int cnt = 0;

            for (int i = 0; i < R; ++i)

                cnt += a[i][j];

            ans += std::max(cnt, R - cnt);

        }

    }

    else {

        ans = dfs(cur + 1);

        reverse(cur);

        ans = std::max(ans, dfs(cur + 1));

        //reverse(cur);

    }

    return ans;

}

int solve() {

    return dfs(0);

}

int main() {

    while (scanf("%d%d", &R, &C), R) {

        for (int i = 0; i < R; ++i)

            for (int j = 0; j < C; ++j)

                scanf("%d", &a[i][j]);

        printf("%d\n", solve());

    }

    return 0;

}


// Fastest known solution for this problem: