#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, i, j;
  cin >> n;
  long long int arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long int b = 0;
  long long int ans[n];
  long long int mm = arr[0];
  b += arr[0];
  ans[0] = arr[0];
  for (i = 1; i < n; i++) {
    mm = min(mm, arr[i]);
    b += mm;
    ans[i] = mm;
  }
  for (i = 0; i < n; i++) {
    long long int sm[i + 1];
    sm[i] = arr[i];
    mm = sm[i];
    long long int temp[n];
    for (j = i - 1; j >= 0; j--) {
      mm = min(mm, arr[j]);
      sm[j] = mm;
    }
    long long int ct = 0;
    for (j = 0; j <= i; j++) {
      ct += min(arr[j], sm[j]);
      temp[j] = min(arr[j], sm[j]);
    }
    mm = arr[i];
    for (j = i + 1; j < n; j++) {
      mm = min(mm, arr[j]);
      ct += mm;
      temp[j] = mm;
    }
    if (ct > b) {
      long long int k = 0;
      b = ct;
      for (k = 0; k < n; k++) {
        ans[k] = temp[k];
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t > 0) {
    t--;
    solve();
  }
}
