#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int tot = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    tot += a[i];
  }
  long long sumans = 0;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    long long preans = a[i];
    vector<int> b(n);
    b[i] = a[i];
    for (int j = i - 1; j >= 0; j--) {
      b[j] = min(a[j], b[j + 1]);
      preans += b[j];
    }
    for (int j = i + 1; j < n; j++) {
      b[j] = min(a[j], b[j - 1]);
      preans += b[j];
    }
    if (preans > sumans) {
      sumans = preans;
      ans = b;
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
