#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}
//約数の総数を返す
int count_divisor(int n){int c[n/2] = {1}; int n_half = n/2; for(int i=2;i<n_half;i++){if(n%i==0){n /= i;c[i]+=1;i--;if(n>1) continue;else break;}  }int r = 1;for(int i=2;i<n_half;i++){r *= c[i];}return r;}
//各桁の数の和を返す
int dig_num(int n){return (n<10) ? n: dig_num(n/10) + n%10;}

int dig_ord(int n){return (n<10) ? 1: dig_ord(n/10) + 1;}

int main(){
  int N; cin >> N;
  long long s[N+1];  
  s[0] = 0;
  
  long long a;
  for(int i=1;i<N+1;i++){
    cin>> a;
    s[i] = s[i-1]+a;
  }
  sort(s,s+N+1);
  int r = 0;
  long long c;
  int cumu = 0;
  REP(i,N+1){
    if(i==0){c=s[i];}
    else{
      if(c==s[i]){
        cumu++;
        r += cumu;
      }
      else{
        c = s[i];
        cumu = 0;
      }
    }
  }
  
  cout << r << "\n";
}