#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) { return a < b ? a : b; }
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int bn = -1, bs = -1, sum, pv;
  for (int i = 0; i < n; i++) {
    sum = a[i];
    pv = a[i];
    for (int j = i; j > 0; j--) {
      pv = min(pv, a[j - 1]);
      sum += pv;
    }
    pv = a[i];
    for (int j = i; j < n - 1; j++) {
      pv = min(pv, a[j + 1]);
      sum += pv;
    }
    if (sum > bs) {
      bs = sum;
      bn = i;
    }
  }
  int ans[n];
  pv = a[bn];
  for (int j = bn; j > 0; j--) {
    pv = min(pv, a[j - 1]);
    ans[j - 1] = pv;
  }
  pv = a[bn];
  for (int j = bn; j < n - 1; j++) {
    pv = min(pv, a[j + 1]);
    ans[j + 1] = pv;
  }
  ans[bn] = a[bn];
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
}
