裴蜀定理的扩展。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#define maxn 1000050
using namespace std;
int n,a[maxn],ans;
int gcd(int a,int b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    ans=a[1];
    for (int i=2;i<=n;i++) ans=gcd(ans,a[i]);
    printf("%d\n",abs(ans));
    return 0;
}