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: 62ms
Memory: 2540kB
In contest: 1276

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int comp(const void *p,const void *q){
    return (*(int *)q-*(int *)p);
}
int main(){
	long long n,i,j,a[100001]={0},pass,z=0,count;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
	   scanf("%lld",&a[i]);
	}
    qsort(a,n,sizeof(long long),comp);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			count=0;
			if(a[i]%a[j]!=0){
			   z=a[i]+a[j];
			   count=1;
			   break;
			}
		}
		if(count==1)
			break;
	}
	if(z<a[0])
		 z=a[0];
	for(i=0;i<n;i++){
		count=0;
		if(a[i]==1){
		   count++;
		}
	}
	if(count==n-1)
		printf("%d\n",z+1);
	else
		printf("%d\n",z);
}