Result: Accepted
Time: 65ms
Memory: 2572kB
#include <cstdio>
#include <algorithm>
#include <iostream>
#include<cstring>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=100005;
int f(int a)
{
int flag=1;
int b=pow(a,0.5);
for(int i=2;i<=b;i++)
{
if(a%i==0)flag=0;
}
return flag;
}
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
long n,i;
long long a[maxn],maxx;
scanf("%ld",&n);
for(i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
}
sort(a+1,a+n+1,cmp);
maxx=a[1];
for(i=2;i<=n;i++)
{
if(a[1]%a[i]!=0&&a[1]+a[i]>maxx)
maxx=a[1]+a[i];
}
printf("%lld\n",maxx);
}