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: 81ms
Memory: 2496kB
In contest: 1276

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int MAXN=1e5+6;
ll a[MAXN];
bool cmp(ll a,ll b)
{
	return a>b;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n,cmp);
	//for(int i=0;i<n;i++)
		//printf("a[i]:%d\n",a[i]);
	ll tmp=0,TMP=0;
	for(int i=0;i<n;i++)
	{
		bool flag=false;
		for(int j=i+1;j<n;j++)
		{
			if(a[i]%a[j]!=0)
			{
				flag=true;
				tmp=a[j];
				//printf("i:%d,j:%d\n",i,j);
				break;
			}
		}
		if(flag)
		{
			TMP=a[i];
			break;
		}
	}
	printf("%lld\n",max(tmp+TMP,a[0]));
	//system("pause");
	return 0;
}