#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, n, t, p = INT_MAX, j = 0, x, a = 0, b, l = 0, r = 0, k = 0,
                         e, w = 0;
  long long sum = 0;
  string s, m;
  cin >> n;
  int ara[n];
  int ar[n];
  int arr[n];
  for (i = 0; i < n; i++) {
    cin >> ara[i];
    ar[j++] = ara[i];
  }
  for (i = 0; i < n; i++) {
    p = ara[i];
    ar[i] = ara[i];
    for (j = i + 1; j < n; j++) {
      if (ara[j] > p) {
        ar[j] = p;
      } else {
        p = ara[j];
        ar[j] = ara[j];
      }
    }
    p = ara[i];
    for (k = i - 1; k >= 0; k--) {
      if (ara[k] > p) {
        ar[k] = p;
      } else {
        p = ara[k];
        ar[k] = ara[k];
      }
    }
    for (int y = 0; y < n; y++) {
      sum += ar[y];
    }
    if (w <= sum) {
      w = sum;
      for (int g = 0; g < n; g++) {
        arr[g] = ar[g];
      }
    }
    sum = 0;
  }
  for (i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  return EXIT_SUCCESS;
}
