#include <bits/stdc++.h>
using namespace std;
#define N 100010
int n;
int arr[N];
vector<int> G[N];
int Stk[N], top;
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
scanf("%d", &n);
int ans = 0;
set<int>s;
for (int i = 1; i <= n; ++i) {
scanf("%d", arr + i);
ans = max(arr[i], ans);
s.insert(arr[i]);
}
sort(arr + 1, arr + 1 + n);
for (int i = n; i >= 1; --i) {
for (int j = i - 1; j >= 1; --j) {
int G = gcd(arr[i], arr[j]);
if (G != arr[i] && G != arr[j]) {
ans = max(ans, arr[i] + arr[j]);
break;
}
}
}
printf("%d\n", ans);
return 0;
}