#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v) {
  os << "[";
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << (i == int(v.size()) - 1 ? "" : ", ");
  }
  os << "]";
  return os;
}
using ll = long long;
int main() {
  int N;
  cin >> N;
  std::vector<ll> a(N), sum(N + 1, 0LL);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    sum[i + 1] += (sum[i] + a[i]);
  }
  std::map<ll, int> mp;
  for (int i = 0; i < N + 1; ++i) {
    mp[sum[i]]++;
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ans += (itr->second * (itr->second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
