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: 68ms
Memory: 1368kB
In contest: 1276

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
bool cmp(const int &a,const int &b){
	return a>b;
}
int gcd(int x,int y){
	if(y==0) return x;
	gcd(y,x%y);
}
int main(){
	int n;
	scanf("%d",&n);
	int sum[100005];
	for(int i=1;i<=n;i++){
	    scanf("%d",&sum[i]);
	}
    sort(sum+1,sum+n+1,cmp);
    int ans1,ans2,max=0;
    ans1=sum[1];
	for(int i=2;i<=n;i++){
		if(sum[i]!=gcd(ans1,sum[i])){
			ans2=sum[i];
			break;
		}
	}
	max=ans1+ans2;
	printf("%d\n",max);
}