#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  long long A[N+10],S[N+10]={},count=0,ans=0;
  for(int i=1; i<=N; i++) cin >> A[i];
   for(int i=1; i<N+1; i++){
    S[i]=S[i-1]+A[i];
  }  sort(S+1,S+N+1);
     for(int i=0; i<N; i++){
       if(S[i]==S[i+1]) count+=1;
       else {ans+=count*(count+1)/2; 
       count=0;
       }
  }ans+=count*(count+1)/2;
  cout << ans << endl;
  }