#include <bits/stdc++.h>
using namespace std;
int n;
long long sum = 0, maxSum = 0;
int fin = 0;
int a[1001];
int b[1001];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int m = 0; m < n; m++) {
    for (int t = 0; t < n; t++) {
      b[t] = a[t];
    }
    sum = b[m];
    for (int j = m - 1; j >= 0; j--) {
      if (b[j] > b[j + 1]) b[j] = b[j + 1];
      sum += b[j];
    }
    for (int j = m + 1; j < n; j++) {
      if (b[j] > b[j - 1]) b[j] = b[j - 1];
      sum += b[j];
    }
    if (sum > maxSum) {
      maxSum = sum;
      fin = m;
    }
  }
  for (int j = fin - 1; j >= 0; j--) {
    if (a[j] > a[j + 1]) a[j] = a[j + 1];
  }
  for (int j = fin + 1; j < n; j++) {
    if (a[j] > a[j - 1]) a[j] = a[j - 1];
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
