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: 59ms
Memory: 2108kB
In contest: 1276

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