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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 10 ;
long long arr[maxn] ;
int main(int argc, char const *argv[])
{
	int n ;
	scanf("%d",&n) ;
	for(int i = 0 ; i < n ; ++ i)
	{
		scanf("%lld",&arr[i]) ;
	}
	sort(arr,arr+n) ;
	int x = arr[n - 1] ;
	int flag = 0 ;
	for(int i = n - 2 ; i >= 0 ; -- i)
	{
		if(x % arr[i] != 0)
		{
			printf("%lld\n",x + arr[i]) ;
			flag = 1 ;
			return 0 ;
		}
	}
	if(flag == 0)
	{
		printf("%lld\n",x) ;
	}
}