#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int table[20001][20001]

int comb(int n, int k)
{
  for (int i = 0; i <= n; i++)
    table[i][0] = 1;
  for (int i = 1; i <= k; i++)
    table[i][i] = 1;

  for (int i = 2; i <= n; i++)
  {
    for (int j = 1; j < min(i, k + 1); j++)
    {
      table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
    }
  }
  return table[n][k];
}

int main()
{
  int n;
  cin >> n;
  vector<ll> s(n+1);
  s[0] = 0;
  REP(i,n){
    ll a;
    cin >> a;
    s[i+1] = s[i] + a;
  }
  unordered_map<ll, int> mp;
  ll ans = 0;
  REP(i,n+1) mp[s[i]]++;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    if(itr->second>1){
      ans += comb(itr->second, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
