#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long v[n];
  for (long long i = 0; i < n; i++) cin >> v[i];
  long long c;
  long long sum1 = 0;
  for (long long i = 0; i < n; i++) {
    long long sum = 0;
    long long h = v[i];
    sum += h;
    for (long long j = i - 1; j >= 0; j--) {
      if (v[j] < h) {
        h = v[j];
      }
      sum += h;
    }
    h = v[i];
    for (long long j = i + 1; j < n; j++) {
      if (v[j] < h) {
        h = v[j];
      }
      sum += h;
    }
    if (sum > sum1) {
      sum1 = sum;
      c = i;
    }
  }
  long long h = v[c];
  for (long long j = c - 1; j >= 0; j--) {
    if (v[j] < h) {
      h = v[j];
    }
    if (v[j] > h) v[j] = h;
  }
  h = v[c];
  for (long long j = c + 1; j < n; j++) {
    if (v[j] < h) {
      h = v[j];
    }
    if (v[j] > h) v[j] = h;
  }
  for (long long i = 0; i < n; i++) {
    cout << v[i] << " ";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  for (long long i = 0; i < t; i++) solve();
}
