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

#define int long long
map < int , int > sum;

signed main(){
	int N , val = 0 , ans = 0; cin >> N; sum[0] = 1;
	for(int i = 1 , x ; i <= N ; ++i){cin >> x; val += x; ans += sum[val]; ++sum[val];}
	cout << ans; return 0;
}
