#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 0;
  vector<int> best(n);
  vector<int> tmp(n);
  for (int i = 0; i < n; ++i) {
    int lef = a[i];
    int rig = a[i];
    long long cnt = a[i];
    int ilef = i;
    int irig = i;
    tmp[i] = a[i];
    while (ilef - 1 >= 0) {
      ilef -= 1;
      lef = min(lef, a[ilef]);
      cnt += lef;
      tmp[ilef] = lef;
    }
    while (irig + 1 < n) {
      irig += 1;
      rig = min(rig, a[irig]);
      cnt += rig;
      tmp[irig] = rig;
    }
    if (cnt > ans) {
      ans = cnt;
      for (int j = 0; j < n; ++j) {
        best[j] = tmp[j];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << best[i] << " ";
  }
  cout << "\n";
  return 0;
}
