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


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000;

int n;
long long a[maxn];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	long long sum=0,Max=a[n-1],t=0;
	for(int i=0;i<n;i++){
		sum=a[i];
		t=0;
		for(int j=n-1;j>i;j--){
			if(a[j]%a[i]!=0){
			t=a[j];
			break;
		}
		}
		sum+=t;
		Max=max(sum,Max);
	}
	printf("%lld",Max);
}