import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;


int N;
long[] A;

void input() {
    scanf("%d\n", &N);
    A = new long[N];
    foreach (i; 0 .. N) {
        scanf("%ld\n", &A[i]);
    }
}

void solve() {

    const INF = 1L << 52;

    auto S = new long[N + 1];
    S[0] = 0;
    foreach (i; 1 .. N + 1) {
        S[i] = S[i - 1] + A[i - 1];
    }

    //writeln(S);

    auto dp = new long[][](N + 1, N + 1);
    foreach (ref L; dp) L[] = INF;
    dp[0][0] = -INF;

    int lower_bound(in long[] xs, long x) {
        int lb = -1, ub = cast(int)(xs.length);
        while (lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            (xs[mid] < x ? lb : ub) = mid;
        }
        return lb;
    }

    auto prev = new int[][](N + 1, N + 1);
    foreach (ref L; prev) L[] = -1;
    foreach (int i; 1 .. N + 1) {
        foreach (int j; 0 .. i) {
            auto x = S[i] - S[j]; // [j, i)縺ョ蜥?            int k = lower_bound(dp[j], x);
            dp[i][k] = min(dp[i][k], dp[j][k]);
            if (dp[i][k + 1] > x) {
                dp[i][k + 1] = x;
                prev[i][k + 1] = j;
            }
        }
    }
    int ans = 0;
    foreach (int i; 0 .. N + 1) {
        if (dp[N][i] != INF) {
            ans = max(ans, i);
        }
    }
    writeln(ans);
    int i = N, k = ans;
    int[] s;
    while (k > 1) {
        s ~= prev[i][k];
        i = prev[i][k];
        k--;
    }
    writefln("%(%s %)", s.reverse);
    //writefln("%(%s\n%)", dp.back);
    //writefln("%(%s\n%)", dp);
}

void main() {
    input; solve;
}