#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const long long int N = 1e9 + 7;
long long int pow(long long int x, long long int y) {
  long long int res = 1;
  while (y > (long long int)0) {
    if (y & (long long int)1) res = ((res) * (x));
    y = y >> (long long int)1;
    x = ((x) * (x));
  }
  return res;
}
long long int powm(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > (long long int)0) {
    if (y & (long long int)1) res = (res * x) % p;
    y >>= (long long int)1;
    x = (x * x) % p;
  }
  return res;
}
void solve() {
  long long int i, j, k, ans, a, b, c, mx, mn, t, n, m, x, temp, p, q, y, z, l,
      r, g, h, flg, sum, d, odd, even, prev, cnt, diff;
  cin >> n;
  vector<long long int> arr(n + 1), arr1(n + 1);
  for (i = 1; i <= n; i++) cin >> arr[i];
  prev = 0;
  for (i = 1; i <= n; i++) {
    k = arr[i];
    x = 0;
    for (j = i - 1; j >= 1; j--) x += (k = min(arr[j], k));
    k = arr[i];
    for (j = i + 1; j <= n; j++) x += (k = min(arr[j], k));
    if (arr[i] + x > prev) prev = arr[i] + x, y = i;
  }
  k = arr[y];
  arr1[y] = arr[y];
  for (i = y + 1; i <= n; i++) arr1[i] = (k = min(arr[i], k));
  k = arr[y];
  for (i = y - 1; i >= 1; i--) arr1[i] = (k = min(arr[i], k));
  for (i = 1; i <= n; i++) cout << arr1[i] << " ";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
}
