#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
const int mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  long long m[n], ans[n], temp[n], sum = 0;
  for (int i = 0; i <= n - 1; i++) cin >> m[i];
  for (int i = 0; i <= n - 1; i++) {
    temp[i] = m[i];
    for (int j = i + 1; j <= n - 1; j++) temp[j] = min(temp[j - 1], m[j]);
    for (int j = i - 1; j >= 0; j--) temp[j] = min(temp[j + 1], m[j]);
    long long tempsum = accumulate(temp, temp + n, 0ll);
    if (tempsum > sum) {
      sum = tempsum;
      for (int j = 0; j <= n - 1; j++) ans[j] = temp[j];
    }
  }
  for (int i = 0; i <= n - 1; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
