#include <bits/stdc++.h>
using namespace std;
int64_t n;
int64_t m[1005], h[1005];
int32_t main() {
  cin >> n;
  for (int64_t i = 1; i <= n; i++) cin >> m[i];
  int64_t mind = -1, mx = -1;
  for (int64_t i = 1; i <= n; i++) {
    h[i] = m[i];
    int64_t sm = h[i];
    for (int64_t j = i - 1; j >= 1; j--) {
      h[j] = min(m[j], h[j + 1]);
      sm += h[j];
    }
    for (int64_t j = i + 1; j <= n; j++) {
      h[j] = min(m[j], h[j - 1]);
      sm += h[j];
    }
    if (sm > mx) {
      mind = i;
      mx = sm;
    }
  }
  int64_t ss = 0;
  h[mind] = m[mind];
  ss += h[mind];
  for (int64_t i = mind - 1; i >= 1; i--) {
    h[i] = min(m[i], h[i + 1]);
    ss += h[i];
  }
  for (int64_t i = mind + 1; i <= n; i++) {
    h[i] = min(m[i], h[i - 1]);
    ss += h[i];
  }
  for (int64_t i = 1; i <= n; i++) {
    cout << h[i] << " ";
  }
  cout << endl;
  return 0;
}
