#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<cmath>
#include<cctype>
#include<algorithm>
#include<cstdio>
using namespace std;
vector<long long> a;
long long gcd(long long x, long long y) {
if(x == y)
return x;
int r = x % y;
while(r) {
x = y;
y = r;
r = x % y;
}
return y;
}
bool cmp(long long x, long long y) {
return x > y;
}
int main(){
int n;
cin >> n;
int i, j;
long long z;
for(i = 0; i < n; i++) {
cin >> z;
a.push_back(z);
}
sort(a.begin(), a.end(), cmp);
long long max;
for(i = 0; i < a.size(); i++) {
if(i == 0)
max = a[0];
for(j = i + 1; j < a.size(); j++) {
if(gcd(a[i], a[j]) == 1 && a[i] + a[j] > max)
max = a[i] + a[j];
}
if(a[i] <= max / 2)
break;
}
cout << max;
return 0;
}