/** * @FileName a.cpp * @Author kanpurin * @Created 2020.05.25 00:36:25 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n; cin >> n; vector< int > a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << a[0] << endl; cout << 1 << endl; return 0; } else if (n == 2) { if (a[0] > a[1]) { cout << a[0] << endl; cout << 1 << endl; } else { cout << a[1] << endl; cout << 2 << endl; } } vector< int > dp(n, 0); dp[0] = a[0]; dp[1] = a[1]; dp[2] = a[0] + a[2]; for (int i = 3; i < n; i++) { dp[i] = max(a[i] + dp[i - 2], a[i] + dp[i - 3]); } vector< int > ans; if (dp[n - 1] > dp[n - 2]) { cout << dp[n - 1] << endl; ans.push_back(n - 1); int t = n - 1; while (t >= 3) { if (dp[t - 2] + a[t] == dp[t]) { ans.push_back(t - 2); t = t - 2; } else if (dp[t - 3] + a[t] == dp[t]) { ans.push_back(t - 3); t = t - 3; } } for (int i = ans.size() - 1; i >= 0; i--) { cout << ans[i] + 1 << " "; } cout << endl; } else { cout << dp[n - 2] << endl; ans.push_back(n - 2); int t = n - 2; while (t >= 3) { if (dp[t - 2] + a[t] == dp[t]) { ans.push_back(t - 2); t = t - 2; } else if (dp[t - 3] + a[t] == dp[t]) { ans.push_back(t - 3); t = t - 3; } } for (int i = ans.size() - 1; i >= 0; i--) { cout << ans[i] + 1 << " "; } cout << endl; } return 0; }