#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[N], s[N+1];
    rep(i, N) {
        cin >> A[i];
    }
    s[0] = 0;
    rep(i, N) {
        s[i+1] = s[i] + A[i];
    }
    sort(s, s+N+1); 

    int t = s[0];
    int k = 0;
    int c[N+1];
    rep(i, N+1) {
        c[i] = 0;
    }   
a
    rep(i, N+1) {
        if(t < s[i]) {
            t = s[i];
            k++;
            c[k]++;
        } 
        else {
            c[k]++;
        }
    }

    rep(i, N+1) {
        cout << c[i] << "\n";
    }

    ll ans = 0;

    rep(i, N+1) {
        if(c[i] == 0) {
            break;
        }
        ans += (ll)c[i]*(c[i]-1)/2;
    }

    cout << ans;
    
    cout << endl;
    return 0;
}