#include<cstdio>
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<queue>
#define ll long long;
using namespace std;

int main(){
  int n; cin >> n;
  ll a[n+1];
  ll temp = 0;
  ll total = 0;
  for(int i = 0; i < n; i++){
    cin >> temp;
    total += temp;
    a[i] = total;    
  }

  a[n] = 0;
  sort(a, a+n+1);
  ll temp = 1;
  ll ans = 0;

  for(int i = 1; i < n+1; i++){
    if(a[i] == a[i-1]){
      temp++;
    } else {
      ans += temp*(temp-1)/2;
      temp = 1;
    }
  }
  ans += temp*(temp - 1)/2;
  cout << ans << endl;
}
