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: 74ms
Memory: 1988kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sz[100010];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&sz[i]);
	}
	sort(sz+1,sz+1+n);
	int max=sz[n];

	for(int i=n;i>=1;i--)
	{
		if(2*sz[i]<max)
			break;
		for(int j=i;j>=1;j--)
		{
			if(sz[j]+sz[i]<=max)
				break;
			else
			{
				if(sz[i]%sz[j]!=0)
					max=sz[i]+sz[j];
			}
		}
	}
	cout<<max<<endl;
	return 0;
}