#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<bool> flag(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int left = 0;
  int right = N - 1;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long MAX = 0;
    int pos = 0;
    bool dir = 0;
    for (int j = 0; j < N; j++) {
      if (!flag[j])
        if (j - left > right - j) {
          if (MAX < A[j] * (j - left)) {
            MAX = A[j] * (j - left);
            pos = j;
            dir = 0;
          }
        } else {
          if (MAX < A[j] * (right - j)) {
            MAX = A[j] * (right - j);
            pos = j;
            dir = 1;
          }
        }
    }
    if (dir)
      right--;
    else
      left++;
    ans += MAX;
    cout << pos << MAX << endl;
    flag[pos] = true;
  }
  cout << ans << endl;
  return 0;
}
