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

#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<iostream>
#include<set>
#include<stdlib.h>
#include<vector>
using namespace std;
const int maxn=1e5+10;
const int inf=0x3f3f3f3f;
int a[maxn];
int cmp(int a,int b){
	return a>b;
}
int main(){
	int n;
	scanf("%d",&n);
	int maxx;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n,cmp);
	maxx=a[1];
	int flag=0;
	int flag1=0;
	for(int i=2;i<=n;i++){
		if(maxx%a[i]!=0){
			flag=1;
			flag1=a[i];
			break;
		}
	}
	if(flag==0){
		printf("%d\n",maxx);
	}
	else{
		printf("%d\n",maxx+flag1);
	}
}