#include <bits/stdc++.h>
using namespace std;
int n;
long long a[1001], mx = 0, vx;
deque<long long> q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) {
    long long nw = a[i];
    long long tx = a[i];
    for (int j = i - 1; j >= 1; j--) {
      tx = min(tx, a[j]);
      nw += tx;
    }
    tx = a[i];
    for (int j = i + 1; j <= n; j++) {
      tx = min(tx, a[j]);
      nw += tx;
    }
    if (nw > mx) {
      mx = nw;
      vx = i;
    }
  }
  q.push_back(a[vx]);
  long long tx = a[vx];
  for (int j = vx - 1; j >= 1; j--) {
    tx = min(tx, a[j]);
    q.push_front(tx);
  }
  tx = a[vx];
  for (int j = vx + 1; j <= n; j++) {
    tx = min(tx, a[j]);
    q.push_back(tx);
  }
  for (int i = 0; i < n; i++) printf("%d ", q[i]);
  printf("\n");
  return 0;
}
