#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, INF = 1e18 + 10, md = 998244353;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long takemod(long long a, long long mod) {
  a %= mod;
  if (a < 0) a += mod;
  return a;
}
long long fast_exp(long long base, long long expo, long long mod) {
  long long res = 1;
  while (expo > 0) {
    if (expo & 1) res = (res * base) % mod;
    base = (base * base) % mod;
    expo >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod) {
  return takemod(fast_exp(takemod(a, mod), mod - 2, mod), mod);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    long long ans = 0;
    int idx = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      vector<int> r(n);
      for (int j = 0; j < n; j++) {
        r[j] = a[j];
      }
      int c1 = 1, c2 = 1;
      for (int j = i - 1; j >= 0; j--) {
        r[j] = min(r[j], r[j + 1]);
      }
      for (int j = i + 1; j < n; j++) {
        r[j] = min(r[j], r[j - 1]);
      }
      long long sum = 0;
      for (int j = 0; j < n; j++) {
        sum += r[j];
      }
      if (sum > ans) {
        ans = sum;
        idx = i;
      }
    }
    for (int j = idx - 1; j >= 0; j--) {
      a[j] = min(a[j], a[j + 1]);
    }
    for (int j = idx + 1; j < n; j++) {
      a[j] = min(a[j], a[j - 1]);
    }
    for (int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << '\n';
  }
  return 0;
}
