#include <bits/stdc++.h>
using namespace std;
vector<long long> ret;
vector<long long> getFactorization(long long n) {
  for (long long i = 1; i <= sqrt(n); i++)
    if (n % i == 0) {
      if (i != n / i)
        ret.push_back(n / i), ret.push_back(i);
      else
        ret.push_back(i);
    }
  return ret;
}
long long modularExponentiation(long long x, long long n, long long mm) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mm;
    x = (x * x) % mm;
    n = n / 2;
  }
  return result;
}
long long modInverse(long long A, long long mm) {
  return modularExponentiation(A, mm - 2, mm);
}
long long checkPrimeNumber(long long n) {
  bool flag = true;
  for (long long i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
long long min(long long a, long long b) { return a > b ? b : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
vector<bool> prime(100000000 + 1, true);
void SieveOfEratosthenes() {
  prime[0] = false;
  prime[1] = false;
  for (long long p = 2; p * p <= 100000000; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= 100000000; i += p) prime[i] = false;
    }
  }
}
vector<long long> Divisors(long long n) {
  vector<long long> ans;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        ans.push_back(i);
      else {
        ans.push_back(i);
        ans.push_back(n / i);
      }
    }
  }
  return ans;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> b(n), res(n);
  long long mx = -1;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) b[j] = a[j];
    sum = a[i];
    for (long long j = i + 1; j < n; j++) {
      if (b[j] > b[j - 1]) b[j] = b[j - 1];
      sum += b[j];
    }
    for (long long j = i - 1; j >= 0; j--) {
      if (b[j] > b[j + 1]) b[j] = b[j + 1];
      sum += b[j];
    }
    if (sum > mx) {
      for (long long j = 0; j < n; j++) res[j] = b[j];
      mx = sum;
    }
  }
  for (auto it : res) cout << it << " ";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
}
