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

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int p[maxn];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,is=0,maxn1=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&p[i]);
	sort(p,p+n,cmp);
	for(int i=0;i<n;i++){
		for(int k=i+1;k<n;k++){
			if(i==k)continue;
			if(p[i]%p[k]!=0&&p[k]%p[i]!=0){
				maxn1=p[i]+p[k];
				is=1;
				break;
			}
		}
		if(is)break;
	}
	if(maxn1<p[0])printf("%d\n",p[0]);
	else printf("%d\n",maxn1);
	return 0;
}