Result: Accepted
Time: 66ms
Memory: 1984kB
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
bool cmp(int a,int b)
{
return a>b;
}
int gcd(int a,int b)
{
return (b>0)?gcd(b,a%b):a;
}
int main()
{
int n;
int a[100010];
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
sort(a+1,a+n+1,cmp);
int maxx=a[1];
for(int i=2;i<=n;i++)
{
if(a[1]%a[i]!=0)
{
maxx=maxx+a[i];
break;
}
}
cout<<maxx<<endl;
return 0;
}