#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long mx = 0;
  vector<long long> ans(n);
  for (long long i = 0; i < n; i++) {
    long long cnt = a[i], mn = a[i];
    vector<long long> tmp(n);
    tmp[i] = a[i];
    for (long long j = i + 1; j < n; j++) {
      if (a[j] >= mn) {
        tmp[j] = mn;
        cnt += mn;
      } else {
        tmp[j] = a[j];
        mn = a[j];
        cnt += mn;
      }
    }
    mn = a[i];
    for (long long j = i - 1; j >= 0; j--) {
      if (a[j] >= mn) {
        tmp[j] = mn;
        cnt += mn;
      } else {
        tmp[j] = a[j];
        mn = a[j];
        cnt += mn;
      }
    }
    if (cnt > mx) {
      mx = cnt;
      for (long long j = 0; j < n; j++) ans[j] = tmp[j];
    }
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  t = 1;
  while (t--) solve();
}
