#include #include #include using namespace std; int DP[1001][2]; int main() { int n; cin >> n; vectorV; for (int i = 0; i < n; i++) { int v; cin >> v; V.push_back(v); for (int k = 0; k < 2; k++) { if (k == 0) { DP[i + 1][1] = DP[i][k] + v; DP[i + 1][0] = DP[i][k]; } else { DP[i + 1][0] = max(DP[i+1][0], DP[i][k]); } } } int max_number = max(DP[n][1], DP[n][0]); cout << max_number << endl; vectornum; for (int i = 0; i < n; i++) { bool which = max_number == DP[n-i][1]; if (which) { num.push_back(n - i); max_number -= V[n - i - 1]; } } sort(num.begin(), num.end()); for (int i = 0; i < num.size(); i++) { if (i)cout << " "; cout << num[i]; } cout << endl; return 0; }