#include <iostream>
#include <map>

typedef long long ll;

int main() {
	int n;
	std::cin >> n;
	ll sum = 0;
	std::map<ll, int> freq;
	freq[0]++;
	ll ans = 0;
	while(n--) {
		int t;
		std::cin >> t;
		sum += t;
		ans += freq[sum];
		freq[sum]++;
	}
	std::cout << ans << std::endl;
}