#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int INF=1000000000;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
main(){
    ll int n;
    cin>>n;
    ll int a[n]={};
    rep(i,n){
        cin>>a[i];
    }
    vector<ll int> v;
    ll int temp=0;
    v.push_back(0);
    rep(i,n){
        temp+=a[i];
        v.push_back(temp);
    }
    sort(v.begin(),v.end());
    ll int mem=v[0];
    ll int memnum=0;
    ll int ans=0;
    rep2(i,0,n){
        while(v[i]==mem){
            i++;
        }
        ans+=(i-memnum)*(i-memnum-1)/2;
        memnum=i;
        mem=v[i];

    }
    cout<<ans;
    return 0;
}