#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

typedef long long ll;
ll n, a, s, c;
map<ll, ll> m;
int main()
{
	cin >> n;
	m[0] = 1;
	while (n--) {
		scanf("%lld", &a);
		s += a;
		c += m[s];
		m[s]++;
	}
    cout << c << endl;
    return 0;
}