#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int64_t> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int64_t> s(N + 1, 0);
  for (int i = 0; i < N; i++) {
    s.at(i + 1) = s.at(i) + a.at(i);
  }
  map<int64_t, int> counter;
  for (int i = 0; i < N + 1; i++) {
    counter[s.at(i)] += 1;
  }
  int64_t total = 0;
  for (auto it : counter) {
    total += it.second * (it.second - 1) / 2;
  }
  cout << total << endl;
  return 0;
}
