#include <bits/stdc++.h>
using namespace std;
long long Ceil(long long a, long long b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool isSubSequence(string str1, string str2, int m, int n) {
  if (m == 0) return true;
  if (n == 0) return false;
  if (str1[m - 1] == str2[n - 1])
    return isSubSequence(str1, str2, m - 1, n - 1);
  return isSubSequence(str1, str2, m, n - 1);
}
void SieveOfEratosthenes(long long n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = -1;
  long long ind;
  for (long long i = 0; i < n; i++) {
    long long sum = a[i];
    long long cur = a[i];
    for (long long j = i - 1; j >= 0; j--) {
      sum += min(a[j], cur);
      cur = min(cur, a[j]);
    }
    long long sum2 = a[i];
    cur = a[i];
    for (long long j = i + 1; j < n; j++) {
      sum2 += min(a[j], cur);
      cur = min(cur, a[j]);
    }
    if (sum + sum2 - a[i] > ans) {
      ans = sum + sum2 - a[i];
      ind = i;
    }
  }
  for (long long i = ind - 1; i >= 0; i--) {
    a[i] = min(a[i + 1], a[i]);
  }
  for (long long i = ind + 1; i < n; i++) {
    a[i] = min(a[i - 1], a[i]);
  }
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
