Result: Accepted
Time: 60ms
Memory: 1796kB
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int comp(const void *p,const void *q)
{
return (*(int*)q-*(int*)p);
}
int main(){
int n,a[110000],i,m,j,flag;
scanf("%d",&n);
for(i=0;i<n;++i)
{
scanf("%d",&a[i]);
}
qsort(a,n,sizeof(int),comp);
flag=0;
for(i=0;i<n;++i)
{
for(j=i+1;j<n;++j)
{
if(a[j]!=0&&a[i]!=0){
if(a[i]%a[j]!=0&&a[j]%a[i]!=0)
{
m = a[i]+a[j];
flag=1;
break;
}
}
}
if(flag==1)
{
break;
}
}
if(flag==1)
{
printf("%d\n",m);
}
else
{
printf("%d\n",a[0]);
}
}