#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2")
using namespace std;
const long long inf = 1e10;
void print(vector<long long>& a) {
  for (int i = 1; i < a.size(); ++i) cout << a[i] << " ";
  cout << "\n";
}
vector<long long> get(int ind, vector<long long>& a) {
  long long n = a.size() - 1;
  vector<long long> ans(n + 1, 0);
  ans[ind] = a[ind];
  for (int i = ind + 1; i <= n; ++i) {
    ans[i] = min(a[i], ans[i - 1]);
  }
  for (int i = ind - 1; i > 0; --i) {
    ans[i] = min(a[i], ans[i + 1]);
  }
  return ans;
}
long long sum(vector<long long>& a) {
  long long s = 0;
  for (int i = 1; i < a.size(); ++i) s += a[i];
  return s;
}
int main() {
  cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long> a(n + 1), ans(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  if (n == 1) {
    cout << a[1];
    exit(0);
  }
  a[0] = inf;
  long long sm = 0;
  for (int i = 1; i <= n; ++i) {
    auto c = get(i, a);
    long long cur = sum(c);
    if (cur >= sm) {
      ans.swap(c);
      sm = cur;
    }
  }
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  return 0;
}
