#include using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--) #define all(a) (a).begin(),(a).end() typedef long long ll; typedef pair P; typedef vector V; typedef vector> VV; signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int N; cin >> N; V v(N + 1, 0); rep(i, N) cin >> v[i + 1]; V dp(N + 1, 0); dp[1] = v[1]; rep2(i, 2, N + 1) { dp[i] = max(dp[i - 1], dp[i - 2] + v[i]); } cout << dp[N] << endl; V ans; for (int i = N; i > 0; ) { if (i - 2 >= 0 && dp[i] == dp[i - 2] + v[i]) { ans.emplace_back(i); i -= 2; } else { if (i == 1) ans.emplace_back(i); i -= 1; } } reverse(all(ans)); rep(i, ans.size()) { cout << ans[i] << (i != ans.size() - 1 ? " " : ""); } cout << endl; }