#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
ll n, a, s, ans;
map<ll, ll> mp;
int main() {
	scanf("%lld", &n);
	mp[0] = 1;
	while(n--) {
		scanf("%lld", &a);
		s += a;
		ans += mp[s];
		mp[s]++;
	}
	printf("%lld", ans);
	return 0;
}