#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
int n;
scanf("%d",&n);
int maxx = -INF;
int ji = 0;
int ou = 0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
maxx = max(maxx,a[i]);
}
int m = 0;
for(int i=0;i<n;i++)
{
if(a[i] != maxx)
{
if(maxx % a[i] != 0)
m = max(m,a[i]);
}
}
printf("%d\n",maxx + m);
}