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