#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int n,a[100010],i,j,t;
int main(){
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&a[i]);
}
if(n==1) printf("%d",a[n]);
else{
sort(a+1,a+1+n);
t=0;
for(i=n;i>=1;i--){
for(j=i-1;j>=1;j--){
if(a[i]%a[j]!=0){
if(a[i]+a[j]>t) t=a[i]+a[j];
break;
}
}
}
if(t==0) t=a[n];
printf("%d\n",t);
}
}