#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long sum = 0;
  long long ans;
  vector<long long> res(n);
  for (long long i = 0; i < n; i++) {
    long long temp = arr[i];
    long long ps = arr[i];
    long long l = i;
    for (long long j = i - 1; j >= 0; j--) {
      temp = temp + min(arr[j], ps);
      ps = min(ps, arr[j]);
    }
    ps = arr[i];
    for (long long k = i + 1; k < n; k++) {
      temp = temp + min(arr[k], ps);
      ps = min(ps, arr[k]);
    }
    if (temp > sum) {
      ans = i;
      sum = temp;
    }
  }
  long long ps = arr[ans];
  res[ans] = arr[ans];
  for (long long j = ans - 1; j >= 0; j--) {
    ps = min(ps, arr[j]);
    res[j] = ps;
  }
  ps = arr[ans];
  for (long long k = ans + 1; k < n; k++) {
    ps = min(ps, arr[k]);
    res[k] = ps;
  }
  for (auto x : res) cout << x << " ";
}
