#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(int, const char**) {
  int n;
  cin >> n;
  vector<ll> s(n + 1, 0);
  for (int i = 0; i < (int)(n); ++i) {
    ll a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  sort(s.begin(), s.end());
  ll t = 0;
  int c = 0;
  ll ans = 0;
  for (int i = 0; i < (int)(n + 1); ++i) {
    if (s[i] == t) {
      c++;
    } else {
      if (c >= 2) {
        ans += (c * (c - 1) / 2);
      }
      c = 1;
      t = s[i];
    }
  }
  if (c >= 2) {
    ans += (c * (c - 1) / 2);
  }
  cout << ans << endl;
  return 0;
}
