Result: Accepted
Time: 76ms
Memory: 2380kB
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<queue>
using namespace std;
const int maxn=1e5+9;
const int inf=0x3f3f3f3f;
typedef long long ll;
bool cmp(const ll &a,const ll &b){
return a>b;
}
int main(){
ll n,num[maxn];
scanf("%lld",&n);
for(ll i=1;i<=n;i++) scanf("%lld",&num[i]);
sort(num+1,num+1+n,cmp);
ll ans=0;
for(ll i=2;i<=n;i++){
if(num[1]%num[i]==0) continue;
else{
ans=num[i];
break;
}
}
printf("%lld\n",ans+num[1]);
return 0;
}