#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const double PI = 3.14159265359;
int n, k1, k2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> v(n), cs(n);
  for (auto& i : v) cin >> i;
  cs[0] = v[0];
  for (int i = 1; i < n; i++) {
    cs[i] = cs[i - 1] + v[i];
  }
  map<int, int> m;
  for (auto i : cs) {
    auto it = m.find(i);
    if (it == m.end()) {
      m[i] = 1;
    } else {
      it->second++;
    }
  }
  long long ans = 0;
  for (auto p : m) {
    ans += p.second * (p.second - 1) / 2;
    if (!p.first) ans += p.second;
  }
  cout << ans;
  return 0;
}
