#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
int n;
  int k[n];
  rep(i, n)cin>>k[i];
    int sumsum[n];
  rep(i, n){if(!i) sumsum[i]=k[0];
    else sumsum[i]=sumsum[i-1]+k[i];}
  
  sort(sumsum,sumsum+n);
  
  int renzoku=0;
  int renx[n]={0};
  bool counting=false;
  for(int i=1;i<=n-1;i++){
    if(counting){if(sumsum[i]==sumsum[i-1])
    {renzoku++;
                 if(i==n-1) renx[n-1]=renzoku;}

                 else {renx[i-1]=renzoku;
                 renzoku=0;
  counting=false;}
                }
      
      
      if(sumsum[i]==sumsum[i-1]){
        counting=true;
        renzoku=2;
        if(i==n-1) renx[n-1]=2;
      }
  }
  
  int ans=0;
  rep(i, n){ans+=renx[i]*(renx[i]-1)/2;}
  
  cout<<ans<<endl;


}
