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