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: 2108kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
const int maxn=100010;
int a[maxn];
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
int main ()
{
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+t);
	int lazy=0;
	for(int i=t-2;i>=0;i--)
	{
		if(gcd(a[t-1],a[i])==1)
		{
			lazy=1;
			printf("%d",a[t-1]+a[i]);
		}
		if(lazy==1)break;
	}
	if(lazy==0)
	{
		printf("%d",a[t-1]);
	}
}