#include <bits/stdc++.h>
using namespace std;
long long bin_pow(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long t = bin_pow(a, b / 2);
    return t * t % 1000000007;
  } else
    return a * bin_pow(a, b - 1) % 1000000007;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1, n, m, z, x, y, c, r, s, b, k;
  while (t--) {
    s = 0;
    cin >> n;
    vector<long long> a(n), m(n), b(n);
    for (int i = 0; i < n; i++) cin >> m[i];
    a[0] = s = m[0];
    for (int i = 1; i < n; i++) {
      if (m[i] > a[i - 1])
        a[i] = a[i - 1], s += a[i];
      else
        a[i] = m[i], s += a[i];
    }
    long long s1 = 0;
    b[n - 1] = s1 = m[n - 1];
    for (int i = n - 2; i >= 0; i--) {
      if (m[i] > b[i + 1])
        b[i] = b[i + 1], s1 += b[i];
      else
        b[i] = m[i], s1 += b[i];
    }
    if (s1 > s) {
      for (int i = 0; i < n; i++) a[i] = b[i];
      s = s1;
      s1 = 0;
    }
    for (int i = 1; i < n - 1; i++) {
      s1 = b[i] = m[i];
      for (int j = i - 1; j >= 0; j--) {
        if (m[j] > b[j + 1])
          b[j] = b[j + 1], s1 += b[j];
        else
          b[j] = m[j], s1 += b[j];
      }
      for (int j = i + 1; j < n; j++) {
        if (m[j] > b[j - 1])
          b[j] = b[j - 1], s1 += b[j];
        else
          b[j] = m[j], s1 += b[j];
      }
      if (s1 > s) {
        for (int j = 0; j < n; j++) a[j] = b[j];
        s = s1;
        s1 = 0;
      }
    }
    for (auto u : a) cout << u << " ";
    cout << "\n";
  }
  return 0;
}
