#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll S[N+1] = {};
    rep(i, N) S[i+1] = S[i] + A[i];
    sort(S, S+(N+1));
    int row = 1;
    ll aim = S[0];
    ll ans = 0;
    rep(i, N){
        if(S[i+1] == aim){
            row++;
        }
        else{
            ans += row*(row-1)/2;
            row = 1;
            aim = S[i+1];
        }
    }
    ans += row*(row-1)/2;
    cout << ans << endl;
    return 0;
}

void solve(){}