#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> vec(n), ans(n), cur(n);
  int64_t maxres = -1, res = 0;
  for (int64_t i = 0; i < n; i++) {
    cin >> vec[i];
  }
  for (int64_t j = 0; j < n; j++) {
    res += vec[j];
    int64_t maxh = vec[j];
    cur[j] = maxh;
    for (int64_t i = j - 1; i >= 0; i--) {
      res += min(maxh, vec[i]);
      maxh = min(maxh, vec[i]);
      cur[i] = maxh;
    }
    maxh = vec[j];
    for (int64_t i = j + 1; i < n; i++) {
      res += min(maxh, vec[i]);
      maxh = min(maxh, vec[i]);
      cur[i] = maxh;
    }
    if (res > maxres) {
      ans = cur;
      maxres = res;
    }
    res = 0;
  }
  for (int64_t i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
