#include <bits/stdc++.h>
using namespace std;

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    int N,
    ll r=0;
    cin >> N;
    vector<ll> v(N);
    map<ll,int> mp;
    for (int i=0;i<N;++i) {
        cin >> v[i];
        if (i>0) v[i] += v[i-1];
        mp[v[i]] += 1;
    }


    for (auto it=mp.begin();it!=mp.end();++it) {
        if (it->first==0) r += it->second;
        r += (it->second)*(it->second-1)/2;
    }
    cout << r << endl;    
}