#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int dp[1010][2]; int p[1010][2]; vector ans; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int v; cin >> v; dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]); if (dp[i - 1][0] > dp[i - 1][1]) p[i][0] = 0; else p[i][0] = 1; dp[i][1] = dp[i - 1][0] + v; p[i][1] = 0; } cout << max(dp[n][0], dp[n][1]) << endl; int now; if (dp[n][0] > dp[n][1]) now = 0; else now = 1; for (int i = n; i > 0; i--) { if (now == 1) { ans.emplace_back(i); } now = p[i][now]; } for (int i = ans.size() - 1; i >= 0; i--) { cout << ans[i]; if (i != 0) { cout << " "; } } cout << endl; }