#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a & b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
map<long long, long long> s;
int a[200005];
int main() {
  long long n, sum = 0, count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    s[sum]++;
    cout << sum << endl;
  }
  map<long long, long long>::iterator it;
  for (it = s.begin(); it != s.end(); it++) {
    long long x = it->second;
    cout << x << endl;
    if (x > 1) {
      count += x * (x - 1) / 2;
    }
    if (it->first == 0) {
      count += it->second;
    }
  }
  cout << count << endl;
  return 0;
}
