#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int N; vi V; int dp[1001][2], pre[1001][2]; int main(){ cin >> N; V.resize(N); rep(i, N)cin >> V[i]; MEM(dp, -1); dp[0][0] = 0; auto f = [&](int nj, int i, int j){ int val = dp[i][j] + V[i] * nj; if(val > dp[i+1][nj]){ dp[i+1][nj] = val; pre[i + 1][nj] = j; } }; rep(i, N)rep(j, 2){ if(j == 0) f(1, i, j); f(0, i, j); } int jj = dp[N][0] > dp[N][1] ? 0 : 1; printf("%d\n", dp[N][jj]); vi ans; for(int i = N - 1; i >= 0; i--){ if(jj == 1)ans.push_back(i+1); jj = pre[i + 1][jj]; } reverse(all(ans)); rep(i, sz(ans))cout << ans[i] << (i != sz(ans) - 1 ? ' ' : '\n'); }