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

#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    sort(a,a+n,greater<int>());
    int ans=a[0];
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)if(a[i]%a[j]!=0)
        {
            ans=max(ans,a[i]+a[j]);
            break;
        }
    }
    printf("%d\n",ans);
}