#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (auto &it : a) cin >> it;
  vector<long long> ans = a;
  long long mx = 0;
  for (long long i = 0; i < n; i++) {
    vector<long long> v = a;
    long long cur = v[i];
    long long last = v[i];
    for (long long j = i - 1; j >= 0; j--) {
      v[j] = min(v[j], last);
      cur += v[j];
      last = v[j];
    }
    last = v[i];
    for (long long j = i + 1; j < n; j++) {
      v[j] = min(v[j], last);
      cur += v[j];
      last = v[j];
    }
    if (cur > mx) {
      mx = cur;
      ans = v;
    }
  }
  for (long long i : ans) cout << i << " ";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
