#include <bits/stdc++.h>
using namespace std;
long long sum[999999], a[999999];
long long comb2(int a) {
  if (a == 0) return 0;
  long long ret = a * (a - 1) / 2;
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  sort(sum, sum + n);
  long long ans = 0;
  sum[n + 1] = sum[n] - 1;
  for (int i = 0; i <= n; i++) {
    int tmp = 0;
    for (int j = i; j <= n + 1; j++) {
      printf("%d %d %d %d\n", i, sum[i], j, sum[j]);
      if (sum[i] == sum[j])
        tmp++;
      else {
        i = j - 1;
        break;
      }
    }
    ans += comb2(tmp);
    printf("%d\n", ans);
  }
  printf("%lld\n", ans);
}
