Result: Accepted
Time: 60ms
Memory: 2496kB
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;
int T,n,flag;
long long sum;
const int maxn=100010;
long long a[maxn];
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%ld",&a[i]);
}
sort(a,a+n);
for(int i=n-1;i>=0;i--){
sum=0,flag=0;
for(int j=i-1;j>=0;j--){
if(a[i]%a[j]!=0){
sum=a[i]+a[j];
flag=1;
break;
}
else continue;
}
if(flag==1)
break;
}
if(sum!=0)
printf("%ld\n",sum);
else printf("%ld\n",a[n-1]);
return 0;
}