#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << " = " << a << " ";
    call(++it, ed, rest...);
  }
};
const double GOLD = (1.0 + sqrt(5.0)) / 2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;
long long int expo(long long int a, long long int n) {
  long long int result = 1;
  while (n) {
    if (n % 2) result *= a;
    a *= a;
    n /= 2;
  }
  return result;
}
long long int mod_expo(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
struct result {
  vector<int> temp;
  long long int sum = 0;
};
bool compare(result a, result b) { return a.sum > b.sum; }
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  vector<result> check;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i != v.size(); i++) {
    result r0;
    r0.temp = v;
    for (int j = i - 1; j >= 0; j--)
      r0.temp[j] = min(r0.temp[j + 1], r0.temp[j]);
    for (int j = i + 1; j != r0.temp.size(); j++)
      r0.temp[j] = min(r0.temp[j - 1], r0.temp[j]);
    for (int j = 0; j != r0.temp.size(); j++) r0.sum += r0.temp[j];
    check.push_back(r0);
    result r1;
    r1.temp = v;
    int left_high_side_min_value = INT_MAX;
    for (int j = i - 1; j >= 0; j--)
      left_high_side_min_value = min(left_high_side_min_value, r1.temp[j]);
    if (left_high_side_min_value >= v[i]) {
      for (int j = 1; j < i; j++) {
        r1.temp[j] = min(r1.temp[j - 1], r1.temp[j]);
      }
      for (int j = i + 1; j < r1.temp.size(); j++)
        r1.temp[j] = min(r1.temp[j - 1], r1.temp[j]);
      for (int j = 0; j != r1.temp.size(); j++) r1.sum += r1.temp[j];
      check.push_back(r1);
    }
    result r2;
    r2.temp = v;
    int right_high_side_min_value = INT_MAX;
    for (int j = i + 1; j != r2.temp.size(); j++)
      right_high_side_min_value = min(right_high_side_min_value, r2.temp[j]);
    if (right_high_side_min_value >= v[i]) {
      for (int j = r2.temp.size() - 2; j > i; j--) {
        r2.temp[j] = min(r2.temp[j + 1], r2.temp[j]);
      }
      for (int j = i - 1; j >= 0; j--)
        r2.temp[j] = min(r2.temp[j + 1], r2.temp[j]);
      for (int j = 0; j != r2.temp.size(); j++) r2.sum += r2.temp[j];
      check.push_back(r2);
    }
  }
  sort(check.begin(), check.end(), compare);
  for (int x : check[0].temp) cout << x << " ";
  cout << endl;
  cerr << "time = " << clock() << " ms" << '\n';
  return 0;
}
