#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    a[i + 1] += a[i];
  }
  unordered_map<ll, ll> um;
  for (int i = 0; i < n; i++) {
    um[a[i]]++;
  }
  ll ans = 0;
  for (auto& v : um) {
    if (v.first == 0) {
      ans += v.second;
    }
    if (v.second > 1) {
      ans += v.second * (v.second - 1) / 2;
    }
  }
  cout << ans << "\n";
  return 0;
}
