#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=1,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,S+N+1);
  long long temp=S[0];
  for(int i=1; i<=N+1; i++){
    if(temp==S[i]){
      ans+=count;
      count+=1;
    }else{
      temp=S[i];
      count=1;
    }
  }
 cout << ans << endl;
  }