#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
long long m[maxn];
long long a[maxn];
long long check(int pos, int N) {
  long long sum = 0;
  a[pos] = m[pos];
  for (int i = pos + 1; i <= N; i++) a[i] = min(a[i - 1], m[i]);
  for (int i = pos - 1; i >= 1; i--) a[i] = min(a[i + 1], m[i]);
  for (int i = 1; i <= N; i++) sum += a[i];
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  int T = 1;
  while (T--) {
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> m[i];
    int pos = -1;
    long long sum = -1;
    for (int i = 1; i <= N; i++) {
      long long s = check(i, N);
      if (s >= sum) {
        sum = s;
        pos = i;
      }
    }
    a[pos] = m[pos];
    for (int i = pos + 1; i <= N; i++) a[i] = min(a[i - 1], m[i]);
    for (int i = pos - 1; i >= 1; i--) a[i] = min(a[i + 1], m[i]);
    for (int i = 1; i <= N; i++) cout << a[i] << ' ';
  }
  return 0;
}
