#include <bits/stdc++.h>

using namespace std;
 
int main(){
    unordered_map<long long, int> count;
	int n; cin >> n;
	++count[0];
	long long result{}, current{};
	for(int i = 0 ; i < n ; i++){
		int x; cin >> x;
		current += x;
		result += count[current];
		++count[current];
	}
	cout << result << endl;
}
