#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> data(n), ans(n);
  long long suma = 0;
  for (auto &i : data) cin >> i;
  for (int i = 0; i < n; ++i) {
    vector<int> data1;
    data1 = data;
    for (int j = i - 1; j >= 0; --j) data1[j] = min(data1[j], data1[j + 1]);
    for (int j = i + 1; j < n; ++j) data1[j] = min(data1[j], data1[j - 1]);
    long long sum = 0;
    for (auto i : data1) sum += i;
    if (sum > suma) {
      suma = sum;
      ans = data1;
    }
  }
  for (auto i : ans) cout << i << " ";
  return 0;
}
