#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
	int n,a[200010];
	long long sum[200010];
	cin >> n;
	sum[0] = 0;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		sum[i] = sum[i-1] + a[i];
	}
	sort(sum,sum+n+1);
	long long ans = 0
    long long now = 0;
  	long long cnt = 1;
	for(int i=1; i<=n; i++){
		if(now == sum[i]){
			cnt++;
		}
		else{
			ans += (cnt * (cnt-1)) / 2;
			now = sum[i];
			cnt = 1;
		}
	}
	cout << ans + (cnt * (cnt-1)) / 2 << endl;
	
	return 0;
}
