#include #include #include using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,(int)(n)-1,0) #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP(i,0,(int)(n)-1) #define INF 100000000 typedef long long ll; int main() { int i, n; int dp[2][1000], v[1000]; vector ans; cin >> n; rep (i,n) cin >> v[i]; dp[0][0] = 0; dp[1][0] = v[0]; REP (i,1,n-1) { dp[0][i] = max(dp[0][i-1],dp[1][i-1]); dp[1][i] = dp[0][i-1] + v[i]; } int taste = max(dp[0][n-1],dp[1][n-1]); cout << taste << endl; rrep (i,n) { if (dp[1][i] == taste) { ans.push_back(i+1); taste -= v[i]; } } rrep (i,ans.size()) cout << ans[i] << " "; cout << endl; return 0; }