#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f, N=1e5+10;
LL gcd(LL a, LL b);
int n;
LL a[N];
map<LL, LL> vn, temp;
signed main()
{
cin>>n;
for(int i=1;i<=n;i++) scanf("%lld", &a[i]);
LL res=-INF;
for(int i=1;i<=n;i++)
{
res=max(res, a[i]);
for(auto it=vn.begin();it!=vn.end();it++)
{
LL now_gcd=gcd(it->first, a[i]);
res=max(res, now_gcd*(i-it->second+1));
!temp[now_gcd]?temp[now_gcd]=it->second:temp[now_gcd]=min(temp[now_gcd], it->second);
}
if(!temp[a[i]]) temp[a[i]]=i;
vn=temp, temp.clear();
}
cout<<res<<endl;
}
LL gcd(LL a, LL b)
{
return b?gcd(b, a%b):a;
}