#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll;
using VI = vector<int>;
using VVI =vector<VI>;
using PII pair<int,int>;

#define FOR(i,a,n) for(ll i = (ll)a; i<(ll)n;++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define PB push_back

signed main(void){

	cin.tie();
  	ios::sync_with_stdio(false);
  
  	int n;
  	cin >> n;
  	VI a(n);
  	REP(i,n) cin >> a[i];
  	
  	VI b(n);
  	b[0] = a[0];
  	FOR(i,1,n) b[i]=a[i]+b[i-1];
  	
  	int ret=0;
  	map<int,int> mp;
  	for(int i = n-1; i>=;i--){
    	ret += mp[b[i]];
      	mp[b[i]]++;
    }
  	
  	cout << ret + mp[0] << endl;
  	
  	return 0; 
    
    
    }






}