#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    ll n,x,ans=0;
    cin>>n;
    ll a[n]={0};
    rep(i,n) {
        cin>>x;
        for(int j=i;j<n;j++)a[j]+=x;
    }
    map<ll,ll> q;
    for(ll x:a)q[x]++;
    for(auto x:q) ans+=x.second*(x.second-1)/2;

    cout<<ans+q[0]<<endl;

    return 0;
}
