Result: Accepted
Time: 59ms
Memory: 2108kB
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string.h>
using namespace std;
typedef long long LL;
int a[100005];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
sort(a+1,a+1+n);
int tmp=1;
double res=a[2]/a[1];
for(int i=2;i<=n;i++)
{
double k=a[i]/a[i-1];
if(k!=res)
{
tmp=0;
break;
}
}
if(tmp==1)
{
printf("%d\n",a[n]);
}
else
{
for(int i=n-1;i>=1;i--)
{
if(a[n]%a[i]!=0)
{
printf("%d\n",a[n]+a[i]);
break;
}
}
}
return 0;
}