#include<bits/stdc++.h>
using namespace std;
int main(){
    map<long long,long long> M;
    long long n;
    cin >> n;
    long long ans = 0;
    M[0] = 1;
    long long S = 0;
    for (long long i= 1; i <= n; i++){
        long long a;
        cin>>a;
        S += a;
        ans += M[S];
        M[S] ++;
    }
    cout<<ans << endl;
}
