#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int m = 0, c = 0, pos = -1, l, r, prev;
  for (int i = 0; i < n; i++) {
    c = a[i];
    prev = a[i];
    for (l = i - 1; l >= 0; l--) {
      if (a[l] > prev) {
        c += prev;
      } else {
        c += a[l];
        prev = a[l];
      }
    }
    prev = a[i];
    for (r = i + 1; r < n; r++) {
      if (a[r] > prev) {
        c += prev;
      } else {
        c += a[r];
        prev = a[r];
      }
    }
    if (c > m) {
      m = c;
      pos = i;
    }
  }
  int i = pos;
  for (l = i - 1; l >= 0; l--) {
    if (a[l] > a[l + 1]) {
      a[l] = a[l + 1];
    }
  }
  for (r = i + 1; r < n; r++) {
    if (a[r] > a[r - 1]) {
      a[r] = a[r - 1];
    }
  }
  for (r = 0; r < n; r++) {
    cout << a[r] << " ";
  }
}
