#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
 
using namespace std;
 
int main()
{
	int N, input, count = 0, ans = 0;
	long long sum = 0;
	vector<int> A;
	vector<long long> s;
 
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> input;
		A.push_back(input);
	}
 
	s.push_back(0);
	for (int i = 0; i < N; i++) {
		sum += A[i];
		s.push_back(sum);
	}
 
	sort(s.begin(), s.end());
 
	long long check = -1;
	for (int i = 0; i < N+1; ++i) {
		if (s[i] != check) {
			check = s[i];
			count = 0;
		}
		else
		{
			count++;
			ans += count;
		} 
	}
 
	cout << ans;
	char qq;
	cin >> qq;
	return 0;