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

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>
#include<queue>
using namespace std;
const int maxn=1e5+50;
const int mod=998244353;
const int INF=0x3f3f3f3f;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
bool cmp(int a,int b)
{
	return a>b;
}
int a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		ans=max(ans,a[i]);
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]%a[j]!=0&&a[j]%a[i]!=0)
			{	
				ans=max(ans,(a[i]+a[j]));
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}