#include using namespace std ; #define pb push_back #define mp make_pair #define infile() freopen("large.in","r",stdin); #define output() freopen("output.txt","w",stdout); #define ll long long #define sc(t); scanf("%d",&t); #define scl(t); scanf("%lld",&t); #define sc2(n,m); scanf("%d%d",&n,&m); #define scl2(n,m); scanf("%lld%lld",&n,&m); #define debug(); printf("tushar\n"); #define N 200005 #define mod 1000000007 #define printi(n) printf("%d",n); #define inf ((1<<29)-1) #define linf ((1LL<<60)-1) const double eps = 1e-9; set < ll > s ; set < int > si ; set < ll > :: iterator it ; vector < ll > v ; vector < int > vi ; int n,m,q,k ; ll a[N] ; int main() { int i , j , t ; sc(n) ; for(i=1;i<=n;i++) scanf("%lld",&a[i]); ll ans = -linf ; for(i=1;i<=n;i++) { ll gcd=a[i] ; ll sum = 0LL; ll maxx= 0LL; for(j=i;j<=n;j++) { gcd = __gcd(gcd,a[j]) ; sum = sum + a[j] ; maxx = max(a[j],maxx) ; ans = max(ans,gcd*(sum-maxx)) ; } } printf("%lld\n",ans); return 0 ; }