#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
 
  int N ;
  int ans = 0 ;
  cin >> N ;
  vector<int> A(N) ;
  rep(i,N) cin >> A.at(i) ;
  vector<int> S(N+1) ;
  S.at(0) = 0 ;
  rep(i,N) S.at(i+1) = S.at(i) + A.at(i) ;
  sort(S.begin(),S.end()) ;
  int count = 0 ;
  rep(i,N+1){
    if( S.at(i) == S.at(i+1) count++ ;
    else{
      ans += ( count+1 )*count / 2 ;
      count = 0 ;
       }
       }
  cout << ans << endl ;
}