#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const int INF=1<<29;

int main(){
	int n; scanf("%d",&n);
	ll a[4000];
	rep(i,n) scanf("%lld",a+i);

	vector<ll> h[4001];
	h[0].push_back(-(1LL<<61));
	rep(i,n){
		ll sum=0;
		for(int j=i;j<n;j++){
			sum+=a[j];
			h[j+1].push_back(sum);
		}
	}
	rep(i,n+1){
		sort(h[i].begin(),h[i].end());
		h[i].erase(unique(h[i].begin(),h[i].end()),h[i].end());
	}

	vector<int> dp[4001];
	vector< pair<int,int> > prev[4001];
	rep(i,n+1){
		dp[i].assign(h[i].size(),-INF);
		prev[i].resize(h[i].size());
	}
	dp[0][0]=0;
	rep(i,n){
		// h[i] の二分探索が正しく動くように, dp[i] を単調増加になるように修正
		int pos[4001]; // pos[j] := ( dp[i][j] の値はもともと dp[i][pos[j]] のもの ) ( 経路復元用 )
		rep(j,dp[i].size()) pos[j]=j;
		rep(j,(int)dp[i].size()-1){
			if(dp[i][j+1]<dp[i][j]){
				dp[i][j+1]=dp[i][j];
				pos[j+1]=pos[j];
			}
		}

		ll sum=0;
		for(int j=i;j<n;j++){
			sum+=a[j];
			int k=lower_bound(h[i].begin(),h[i].end(),sum)-h[i].begin()-1;
			if(k==-1) continue;

			int idx=lower_bound(h[j+1].begin(),h[j+1].end(),sum)-h[j+1].begin();
			if(dp[j+1][idx]<dp[i][k]+1){
				dp[j+1][idx]=dp[i][k]+1;
				prev[j+1][idx]=make_pair(i,pos[k]);
			}
		}
	}

	vector<int> ans;
	int i=n,j=max_element(dp[n].begin(),dp[n].end())-dp[n].begin();
	while(1){
		int tmp_i=prev[i][j].first;
		int tmp_j=prev[i][j].second;
		i=tmp_i;
		j=tmp_j;
		if(i==0) break;
		ans.push_back(i);
	}
	reverse(ans.begin(),ans.end());

	printf("%d\n",ans.size()+1);
	rep(i,ans.size()) printf("%d%s",ans[i],i+1<ans.size()?" ":"");
	puts("");

	return 0;
}