#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 ans = LLONG_MIN; int pos = -1; for(int i=1;i<=n;i++){ dp[i] = a[i]; pre[i] = -1; for(int j=1;j<=i-2;j++){ long long cand = dp[j] + a[i] - C*(i-j); if(cand > dp[i]){ dp[i] = cand; pre[i] = j; } } 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"; //cout << path.size() << "\n"; for(int x: path) cout << x << " "; return 0; }