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

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