#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int64_t> ans(1, 0);
  int64_t ANS = 0;
  int64_t max = 0;
  int now = -1;
  int count = 0;
  for (int i = 1; i < N; i++) {
    max = 0;
    now = -1;
    for (int j = 0; j < i; j++) {
      count = ANS;
      count += ((i - j) * A[i] + (i - ans[j] - abs(j - ans[j])) * A[ans[j]]);
      if (max <= count) {
        now = j;
        max = count;
      }
    }
    ans.push_back(ans[now]);
    ans[now] = i;
    ANS = max;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  cout << ANS << endl;
  return 0;
}
