#include <bits/stdc++.h>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;

LL z = 1;

int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
const int N = 2e5 + 5;
LL sum[N], pre[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		sum[i] = sum[i - 1] + x;
		pre[i] = max(pre[i - 1], sum[i]);
	}
	LL mx = 0, tot = 0;
	for(int i = 1; i <= n; i++){
		mx = max(mx, tot + pre[i]);
		tot += sum[i];
	}
	cout << mx;
	return 0;
}

 /*
    Stay motivated and keep working hard
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define int long long 
#define pb push_back
#define cntbit __builtin_popcount
#define fr first
#define mem(arr, val) memset(arr, val, sizeof(arr))
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--) 
#define md 998244353
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
#define in insert
#define endl "\n"
#define ub  upper_bound
#define lb  lower_bound
#define gcd __gcd
#define setval(a,b) memset(a,b,sizeof(a))
#define lwr lower_bound
#define pii pair<int,int>
#define upr upper_bound
#define ordered_s  et     tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define blk 555
//CANDIDATE MASTER TOH BNKE RHUNGA
//dsu is pel concept
//KMP is pel concept 
int k,n,t,i,j=0,m;
const int N=4e6+5;
int md2;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
 
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}
 
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += md;
  return u;
}
void extgcd(int a,int b, int& x,int& y)
{
    if(b != 0){
        extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
}
//fenwick tree is the best
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    unordered_map <int,int> mp1;
    int mn=*min_element(all(a));
    for(int i=0;i<n;i++)
    {
    	for(int j=1;j*j<=a[i] and j<mn;j++)
    	{
    		if(a[i]%j==0)
    		{
    		mp1[j]=__gcd(mp1[j],a[i]);
    		if(a[i]/j<mn)
    		mp1[a[i]/j]=__gcd(mp1[a[i]/j],a[i]);
    	    }
		}
	}
	int ans=1;
	for(auto it:mp1)
	{
		if(it.fr==it.sc)
		ans++;
	}
	cout<<ans<<endl;
}