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

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;
int T,n,flag;
long long sum;
const int maxn=100010;
long long a[maxn];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%ld",&a[i]);
	}
	sort(a,a+n);
	for(int i=n-1;i>=0;i--){
		sum=0,flag=0;
		for(int j=i-1;j>=0;j--){
			if(a[i]%a[j]!=0){
				sum=a[i]+a[j];
				flag=1;
				break;
			}
			else continue;
		}
		if(flag==1)
		break;
	}
	if(sum!=0)
	printf("%ld\n",sum);
	else printf("%ld\n",a[n-1]);
	return 0;
}