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: 63ms
Memory: 2380kB
In contest: 1276

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 50;
bool cmp(int x, int y)
{
	return x > y;
}
int main()
{
	int n;
	long long ans = 0;
	long long a[maxn];
	scanf("%d", &n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld", &a[i]);
	}
	sort(a+1,a+1+n,cmp);
	int flag = 0;
	for(int i=1;i<=n;i++)
	{
		long long t = a[i];
		for(int j=i+1;j<=n;j++)
		{
			if(t % a[j] != 0)
			{
				ans = t + a[j];
				flag = 1;
				break;
			}
		}
		if(flag) break;
	}
	if(ans == 0) ans = a[1];
	printf("%lld\n", ans);
	return 0;
}