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

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxen=100010;
int a[maxen];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int tot=a[n];
	int maxx=a[n];
	for(int i=n-1;i>=1;--i){
		if(maxx%a[i]!=0){
			tot+=a[i];
			break;
		}
		else{
			continue;
		}
	}
	printf("%d\n",tot);
	return 0;
}