#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  long long mi = 1;
  long long cost = LLONG_MAX;
  for (int i = 1; i <= n; i++) {
    long long newCost = 0;
    long long ii = i - 1;
    long long prev = a[i];
    while (ii > 0) {
      if (a[ii] > prev) {
        newCost += (a[ii] - prev);
      } else {
        prev = a[ii];
      }
      ii--;
    }
    ii = i + 1;
    prev = a[i];
    while (ii < a.size()) {
      if (a[ii] > prev) {
        newCost += (a[ii] - prev);
      } else {
        prev = a[ii];
      }
      ii++;
    }
    if (newCost < cost) {
      cost = newCost;
      mi = i;
    }
  }
  long long i = mi - 1;
  while (i > 0) {
    if (a[i] > a[i + 1]) {
      a[i] = a[i + 1];
    }
    i--;
  }
  i = mi + 1;
  while (i < a.size()) {
    if (a[i] > a[i - 1]) {
      a[i] = a[i - 1];
    }
    i++;
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  cout << endl;
}
