Start: Jun, 28, 2019 08:42:00
2019杭州师范大学第一届程序设计竞赛新生赛
End: Jun, 28, 2019 11:42:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 60ms
Memory: 1796kB
In contest: 1276

#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]);
	}
}