Result: Accepted
Time: 66ms
Memory: 2496kB
#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) ;
}
}