#include <bits/stdc++.h>
using namespace std;
class Map : public map<int64_t, int64_t> {
 public:
  void add(int64_t key) {
    auto itr = this->find(key);
    if (itr == this->end())
      this->emplace(key, 1);
    else
      this->at(key)++;
  }
  uint64_t answer() {
    uint64_t ans = 0;
    for (auto x : *this) {
      if (x.second == 1) continue;
      uint64_t factorial = 1;
      for (uint64_t y = 1; y < x.second; ++y) {
        factorial *= y;
      }
      ans += factorial;
    }
    return ans;
  }
};
int main() {
  int64_t N;
  Map countA;
  cin >> N;
  int64_t sum = 0;
  countA.add(sum);
  for (int64_t n = 0; n < N; ++n) {
    int64_t a;
    cin >> a;
    sum += a;
    countA.add(sum);
  }
  cout << countA.answer() << endl;
  return 0;
}
