#include <bits/stdc++.h>
using namespace std;
int n, m[1001], a[1001], ans[1001], s = 0;
long long tot, sum;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> m[i];
  for (int i = 0; i < n; i++) {
    a[i] = m[i], sum = m[i];
    for (int j = i - 1; j >= 0; j--) a[j] = min(m[j], a[j + 1]), sum += a[j];
    for (int j = i + 1; j < n; j++) a[j] = min(m[j], a[j - 1]), sum += a[j];
    if (tot < sum) {
      tot = sum;
      for (int j = 0; j < n; j++) ans[j] = a[j];
    }
  }
  for (int i = 0; i < n - 1; i++) cout << ans[i] << " ";
  cout << ans[n - 1] << endl;
  cin.clear();
  cin.sync();
  cin.get();
  return 0;
}
