#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, ans = -1;
  cin >> n;
  vector<long long int> m(n), ansv(n);
  for (long long int i = 0; i < n; i++) cin >> m[i];
  for (long long int i = 0; i < n; i++) {
    long long int cl, cr, cnt = m[i];
    vector<long long int> temp(n);
    temp[i] = cnt;
    cl = cr = m[i];
    for (long long int l = i - 1; l >= 0; l--) {
      cl = min(cl, m[l]);
      temp[l] = cl;
      cnt += cl;
    }
    for (long long int r = i + 1; r < n; r++) {
      cr = min(cr, m[r]);
      temp[r] = cr;
      cnt += cr;
    }
    if (cnt > ans) {
      ans = cnt;
      ansv = temp;
    }
  }
  for (auto x : ansv) cout << x << " ";
  cout << endl;
}
