Result: Accepted
Time: 62ms
Memory: 2524kB
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
ll a[maxn],n;
int gcd(ll x,ll y)
{
if(y%x==0)
return 0;
else
{
for(int i=2;i<=sqrt(x)+1;i++)
{
if(x%i==0&&y%i==0)
return 0;
}
return 1;
}
}
int main()
{
ll ans1=0;
scanf("%lld",&n);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]);
sort(a+1,a+1+n);
for(int i=n-1;i>=1;i--)
{
if(gcd(a[i],a[n])==1)
{
ans1=a[i];
break;
}
}
printf("%lld\n",max(a[n],a[n]+ans1));
}