#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  long long maxx = -0x3f3f3f3f, res, ans = -1;
  for (int i = 1; i <= n; i++) {
    long long sum = a[i], res = a[i];
    for (int j = i - 1; j >= 1; j--) {
      if (a[j] < res) {
        sum += a[j];
        res = a[j];
      } else
        sum += res;
    }
    res = a[i];
    for (int j = i + 1; j <= n; j++) {
      if (a[j] < res) {
        sum += a[j];
        res = a[j];
      } else
        sum += res;
    }
    if (sum > maxx) {
      ans = i;
      maxx = sum;
    }
  }
  res = a[ans];
  for (int i = ans - 1; i >= 0; i--) {
    if (a[i] < res)
      res = a[i];
    else
      a[i] = res;
  }
  res = a[ans];
  for (int i = ans + 1; i <= n; i++) {
    if (a[i] < res)
      res = a[i];
    else
      a[i] = res;
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
}
