#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  vector<long long> ans(n);
  for (int i = 0; i < n; ++i) {
    ans[i] = v[i];
    int mn = v[i];
    for (int j = i - 1; j >= 0; --j) {
      ans[i] += min(mn, v[j]);
      mn = min(mn, v[j]);
    }
    mn = v[i];
    for (int j = i + 1; j <= n - 1; ++j) {
      ans[i] += min(mn, v[j]);
      mn = min(mn, v[j]);
    }
  }
  long long mx = 0;
  int ind;
  for (int i = 0; i < n; ++i) {
    if (ans[i] > mx) {
      mx = ans[i];
      ind = i;
    }
  }
  vector<int> fans(n);
  int mn = v[ind];
  fans[ind] = v[ind];
  for (int j = ind - 1; j >= 0; --j) {
    fans[j] = min(mn, v[j]);
    mn = min(mn, v[j]);
  }
  mn = v[ind];
  for (int j = ind + 1; j <= n - 1; ++j) {
    fans[j] = min(mn, v[j]);
    mn = min(mn, v[j]);
  }
  for (int i = 0; i < n; ++i) {
    cout << fans[i] << " ";
  }
}
