Result: Accepted
Time: 70ms
Memory: 2108kB
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100010;
const int inf =0x3f3f3f3f;
int n,m,k;
ll t;
int x,y;
int a[maxn];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d",&a[i]);
}
sort(a+1,a+1+n);
ll ans=a[n];
for(int i=1;i<=n;++i)
{
t=0;
for(int j=n;j>=i+1;--j)
{
if(a[j]%a[i]!=0)
{
t=a[i]+a[j];
break;
}
}
ans=max(ans,t);
}
printf("%lld\n",ans);
}