Result: Accepted
Time: 64ms
Memory: 2108kB
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=100100;
typedef long long ll;
int a[maxn];
ll temp;
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",a+i);
}
sort(a,a+n);
for(int i=n-2;i>=0;i--){
temp=a[n-1]+a[i];
if(temp%a[n-1]!=0&&temp%a[i]!=0){
printf("%lld\n",temp);
return 0;
}
}
printf("%d\n",a[n-1]);
return 0;
}