#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> arr(n + 1), pre_sum(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    pre_sum[i] = pre_sum[i - 1] + arr[i];
  }
  sort(pre_sum.begin(), pre_sum.end());
  long long ans = 0;
  int curr = 1;
  for (int i = 1; i <= n; ++i) {
    if (pre_sum[i] == pre_sum[i - 1]) {
      ++curr;
    } else {
      ans += (long long)curr * (curr - 1) / 2;
      curr = 1;
    }
  }
  ans += (long long)curr * (curr - 1) / 2;
  cout << ans << "\n";
  return 0;
}
