#include <bits/stdc++.h>
using namespace std;
template <typename F, typename S>
std::ostream& operator<<(ostream& os, const pair<F, S>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (const T& a : v) {
    os << a << ", ";
  }
  os << "]";
  return os;
}
template <typename K, typename V>
ostream& operator<<(ostream& os, const map<K, V>& m) {
  os << "{";
  for (const auto& p : m) {
    os << p.first << ":" << p.second << ", ";
  }
  os << "]";
  return os;
}
int main() {
  long long n;
  cin >> n;
  vector<int> a(n);
  vector<int> cum(n + 1);
  map<long long, long long> cnt;
  cnt[0] += 1;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    cum[i + 1] = cum[i] + a[i];
    cnt[cum[i + 1]] += 1;
  }
  long long total = 0;
  for (auto p : cnt) {
    total += p.second * (p.second - 1) / 2;
  }
  cout << total << endl;
  return 0;
}
