#include using namespace std; using i64 = int64_t; using vi = vector; using vvi = vector; void printvec(vi& x, int size = 0) { cout << x.front(); for (int i = 1; i < (size == 0 ? x.size() : size); i++) { cout << " " << x[i]; } cout << endl; } int main() { int n; cin >> n; vi dp(n + 3); vi as(n); for (int i = 0; i < n; i++) { int v; cin >> v; as[i] = v; dp[i + 3] = max(dp[i] + v, dp[i + 1] + v); } i64 ans = (n == 1 ? dp.back() : max(dp.back(), dp[n + 1])); cout << ans << endl; i64 sum = ans; vi ss; for (int i = n + 2; i >= 3; i--) { if (dp[i] == sum) { ss.push_back(i - 2); sum -= as[i - 3]; } } assert(sum == 0); reverse(ss.begin(), ss.end()); printvec(ss); }