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