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: 79ms
Memory: 1484kB
In contest: 1276

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<stack>
#include<math.h>;
#include<queue>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
bool cmp(int x,int y){
	return x>y;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n,cmp);
	int ans=a[0];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]+a[j]<ans)break;
			if(a[i]%a[j]!=0){
				ans=a[i]+a[j];
				break;
			}
		}
	}
	printf("%d\n",ans);
}