#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include <functional>
#include <limits>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

//https://atcoder.jp/contests/agc023/tasks/agc023_a


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int res = 0;
	vector<int> a, sum, sum2, v, con;
	
	cin>>N;
	
	a.resize(N);
	sum.resize(N+1);
	sum2.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
	}
	
	for(int i = 0; i < N; i++){
		sum[i+1] += sum[i] + a[i];
		v.push_back(sum[i+1]);
	}
	
	v.push_back(0);
	
	sort(v.begin(), v.end());
	
	v.erase(unique(v.begin(), v.end()), v.end());
	
	
	con.resize(v.size());
	
	for(int i = 0; i <= N; i++){
		sum2[i] = lower_bound(v.begin(), v.end(), sum[i]) - v.begin();
	}
	
	con[sum2[0]]++;
	
	for(int i = 0; i < N; i++){
		
		res += con[sum2[i+1]];
		con[sum2[i+1]]++;
	}
	
	cout<<res<<endl;
	
	
	return 0;
}