#include<iostream>
using namespace std;
int cmmdc(int a[100], int s, int d)
{ if(s==d) return a[s];
else
{ int x,y;
x=cmmdc(a,s,(s+d)/2);
y=cmmdc(a,(s+d)/2+1,d);
while(x!=y)
if(x>y) x=x-y;
else y=y-x;
return x;
}
}
int main()
{
int a[100],n,i;
cin>>n;
for(i=1;i<=n;i++) cin>>a[i];
cout<<cmmdc(a,1,n);
system("pause");
return 0;
}
|