#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],b[n+1]={};
  map<long long, int> mp;
  mp[b[0]]++;
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i+1]=a[i]+b[i];
    mp[b[i+1]]++;
  }
  for(int i=0;i<=n;i++){
    ans+=(mp[b[i]]*(mp[b[i]]-1))/2;
    mp[b[i]]=0;
  }
  cout << ans << endl;
  return 0;
}

