#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int dp[200000][2];

int nCr(int n, int r)
{
       if(n<r) return 0;
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

int main() {
  lli ans=0;
  int N;
  cin >>N;
  vector<lli> cumsum(N+1,0);
  rep (i, N)
  {
    if(i==0)
      continue;
    cin >> cumsum[i];
  cumsum[i] += cumsum[i-1];
  }
  sort(ALL(cumsum));
  
  lli judge=1000000001;
  lli keep =1;
  rep(i,1, N+1)
  {
    if(cumsum.at(i)==cumsum.at(i-1))
      {
      keep++;
    }
    else
      {
    ans+=nCr(keep,2);
      keep=1;
    }
    if(i==N)
      {
    ans+=nCr(keep,2);
      keep=1;
    }
    }
  cout << ans << endl;
}

