#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> sum(n + 1, 0);
  map<ll, int> s_map;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
    if (s_map.count(sum[i + 1]) == 0) {
      s_map[sum[i + 1]] = 1;
    } else
      ++s_map[sum[i + 1]];
  }
  ll count = 0;
  for (auto const& s : s_map) {
    ll k = s.first;
    int v = s.second;
    count += v * (v - 1) / 2;
    if (k == 0) count += v;
  }
  cout << count << endl;
  return 0;
}
