#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;
 
 
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  int N;
  cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  int sum[N+1] = {};
  map<int, int> mp;
  mp[0]++;
  for(int i=0;i<N;i++){
    sum[i+1] = sum[i] + A[i];
    mp[sum[i]]++;
  }

  int ans = -1;
  for(auto P : mp){
    ans += P.second*(P.second-1)/2;
  }
  cout << ans << endl;
  
}