#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans = 0, p = 1;
  cin >> N;
  vector<long long> H(N), sum(N + 1);
  for (size_t i = 0; i < N; i++) {
    cin >> H.at(i);
    sum.at(i + 1) = H.at(i) + sum.at(i);
  }
  sort(sum.begin(), sum.end());
  map<int, int> A;
  for (size_t i = 0; i < N + 1; i++) {
    A[sum.at(i)] == 1;
  }
  for (size_t i = 0; i < N + 1; i++) {
    cout << sum.at(i) << endl;
  }
  for (size_t i = 0; i < sum.size() - 1; i++) {
    if (sum.at(i) == sum.at(i + 1)) {
      p++;
      cout << "hoge";
    } else {
      ans += p * (p - 1) / 2;
      p = 1;
    }
  }
  ans += p * (p - 1) / 2;
  cout << ans;
}
