#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,x=1,ans=0,j=0;
	cin >> n;
	vec(a,n);
	vec(s,n);
	cin >> a[0];
	s[0]= a[0];
	FOR(i,1,n){
		cin >> a[i];
		s[i] = s[i-1] + a[i];
	}
	sort(s.begin(),s.end());
	REP(j,n){
        if(s[j]== 0){
            ans++:
        }
        else if(s[j] > 0){
            break;
        }
    }
	REP(i,n){
		if(s[i] == s[i+1]){
			x += 1;
		}
		else{
			ans = ans + x * (x-1) / 2;
			x = 1;
		}
	}
	cout << ans << endl;
 
    return 0;
}