#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	map <ll, ll> was;
	ll ans(0);
	cin >> n;
	was[0] = 1;
	for (ll a, cur(0); n; --n)
	{
		cin >> a;
		cur += a;
		ans += was[cur];
		++was[cur];
	}
	cout << ans;
}
