#include<cstdio>
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,ans = 0,cnt = 1;
  cin >> N;
  ll num,first,second;
  ll t[N+1]={};
  t[0]=0;
  for (int i = 1; i < N+1; i++){
    cin >> num;
    t[i] += t[i-1] + num;
  }
  sort(t,t+N+1);
  first=t[0];
  for(int i=1;i<=N;i++){
    if(first==t[i]){
      cnt++;
    }else{
      ans += cnt*(cnt-1)/2;
      cnt=1;
      first=t[i];
    }
  }
  ans += cnt*(cnt-1)/2;
  cout << ans;
  return 0;
}