Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 62ms
Memory: 2524kB
In contest: 1276

#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));
}