// 基本テンプレート (縮小版) #include using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define int long long template void chmax(T &a, T b) {a = max(a, b);} template void chmin(T &a, T b) {a = min(a, b);} template void chadd(T &a, T b) {a = a + b;} typedef pair pii; typedef long long ll; constexpr ll INF = 1001001001001001LL; constexpr ll MOD = 1000000007LL; int N, v[1010]; int dp[1010][2]; vector vec[1010][2]; signed main() { cin >> N; rep(i,0,N) cin >> v[i]; rep(i,0,N) { dp[i+1][0] = max(dp[i][0], dp[i][1]); if(dp[i][0] >= dp[i][1]) { vec[i+1][0] = vec[i][0]; } else { vec[i+1][0] = vec[i][1]; } dp[i+1][1] = dp[i][0] + v[i]; vec[i+1][1] = vec[i][0]; vec[i+1][1].push_back(i+1); } int ans; vector ret; if(dp[N][0] < dp[N][1]) { ans = dp[N][1]; ret = vec[N][1]; } else { ans = dp[N][0]; ret = vec[N][0]; } sort(ret.begin(), ret.end()); cout << ans << endl; rep(i,0,ret.size()) cout << (i==0 ? "" : " ") << ret[i]; cout << endl; return 0; }