#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  int n;
  cin >> n;
  vector<ll> v(n + 1);
  v[0] = 0;
  for (int i = 0; i < (n); ++i) {
    int tmp;
    cin >> tmp;
    v[i + 1] = v[i] + tmp;
  }
  sort((v).begin(), (v).end());
  ll ans = 0;
  int count = 1;
  for (int i = 0; i < (n + 2); ++i) {
    if (v[i] == v[i + 1])
      ++count;
    else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}
