#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; long long C=0; cin >> n ; vector a(n+1), dp(n+1); vector pre(n+1); for(int i=1;i<=n;i++) cin >> a[i]; long long best_val = LLONG_MIN; int best_pos = -1; long long ans = LLONG_MIN; int pos = -1; for(int i=1;i<=n;i++){ if(i >= 3){ long long val = dp[i-2] + C*(i-2); if(val > best_val){ best_val = val; best_pos = i-2; } } dp[i] = a[i]; pre[i] = -1; if(best_val != LLONG_MIN){ long long cand = a[i] - C*i + best_val; if(cand > dp[i]){ dp[i] = cand; pre[i] = best_pos; } } if(dp[i] > ans){ ans = dp[i]; pos = i; } } vector path; while(pos != -1){ path.push_back(pos); pos = pre[pos]; } reverse(path.begin(), path.end()); cout << ans << "\n"; for(int x: path) cout << x << " "; }