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: 39ms
Memory: 1364kB
In contest: 1276

#include<stdio.h>
#include<string.h>
int main(){
	int n,k,i,j,a[100001],max=0,tmp=0,res=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>max){
			max=a[i];
			k=i;
		}
	}
	for(j=0;j<n;j++){
		if(max%a[j]!=0&&a[j]>tmp&&j!=k){
			res=max+a[j];
			tmp=a[j];
		}
	}
	if(res>max){
		printf("%d\n",res);
	}else{
		printf("%d\n",max);
	}
}