#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1999999999999999997;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  vector<int> ansv(n);
  for (int i = 0; i < n; i++) {
    vector<int> t(n);
    long long z = a[i];
    t[i] = a[i];
    int mx = a[i];
    int s = i - 1;
    int e = i + 1;
    for (; s >= 0; s--) {
      z = z + min(mx, a[s]);
      mx = min(mx, a[s]);
      t[s] = mx;
    }
    mx = a[i];
    for (; e < n; e++) {
      z = z + min(mx, a[e]);
      mx = min(mx, a[e]);
      t[e] = mx;
    }
    if (ans < z) {
      ans = z;
      ansv = t;
    }
  }
  for (auto j : ansv) cout << j << ' ';
}
