#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int N;
int A[2020];
bool ok(int X)
{
	int g=0;
	for(int i=0;i<N;i++)
	{
		int t=gcd(g,A[i]);
		if(t%X==0)g=t;
	}
	return g==X;
}
main()
{
	cin>>N;
	vector<pair<int,int> >X;
	int mA=1e9;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		mA=min(mA,A[i]);
		for(int j=1;j*j<=A[i];j++)if(A[i]%j==0)
		{
			X.push_back(make_pair(j,i));
			if(A[i]/j>j)X.push_back(make_pair(A[i]/j,i));
		}
	}
	sort(X.begin(),X.end());
	int ans=0;
	for(int i=0;i<X.size();)
	{
		if(X[i].first>mA)break;
		int j=i+1;
		int g=A[X[i].second];
		while(j<X.size()&&X[i].first==X[j].first)
		{
			g=gcd(g,A[X[j++].second]);
		}
		if(g==X[i].first)ans++;
		i=j;
	}
	cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto &it: a) cin >> it;
    vector<ll> pre(n+1);
    ll pre_mx = 0, an = 0, pos = 0;
    for (int i = 0; i < n; ++i) {
        pre[i+1] = pre[i] + a[i];
        pre_mx = max(pre_mx, pre[i+1]);
        an = max(an, pos+pre_mx);
        pos += pre[i+1];
    }
    cout << an << '\n';
    return 0;
}
