#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  long long int b[n];
  long long int ind = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int maxif = INT_MIN;
  for (int i = 0; i < n; i++) {
    long long int maxi = a[i];
    long long int s = 0;
    s += a[i];
    for (long long int j = i - 1; j >= 0; j--) {
      if (a[j] > maxi) {
        b[j] = maxi;
        s += b[j];
      } else {
        maxi = a[j];
        b[j] = maxi;
        s += b[j];
      }
    }
    maxi = a[i];
    for (long long int j = i + 1; j < n; j++) {
      if (a[j] > maxi) {
        b[j] = maxi;
        s += b[j];
      } else {
        maxi = a[j];
        b[j] = maxi;
        s += b[j];
      }
    }
    if (s > maxif) {
      ind = i;
      maxif = s;
    }
  }
  long long int i = ind;
  b[i] = a[i];
  long long int maxi = a[i];
  long long int s = 0;
  for (long long int j = i - 1; j >= 0; j--) {
    if (a[j] > maxi) {
      b[j] = maxi;
    } else {
      maxi = a[j];
      b[j] = maxi;
    }
  }
  maxi = a[i];
  for (long long int j = i + 1; j < n; j++) {
    if (a[j] > maxi) {
      b[j] = maxi;
    } else {
      maxi = a[j];
      b[j] = maxi;
    }
  }
  for (long long int i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
}
