#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  int N;
  cin >> N;
  ll a[200100];
  for (int i=0;i<N;i++){
    cin >> t;
    if(i==0){
      a[0]=t;
      continue;
    }
    a[i]=a[i-1]+t;
  }
  sort(a,a+N);
  ll ans=0;
  ll k=1;
  for(int i=0;i<N;i++){
    if(a[i]==a[i+1]){
      k++;
    }
    else{
      ans+=k*(k-1)/2;
      k=1;
    }
  }
  cout << ans+k*(k-1/2);
}
  