#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  std::vector<int> ans(n);
  long long sum = 0;
  for (int ptr = 0; ptr < n; ptr++) {
    long long tmpsum = 0;
    std::vector<int> ans1(n);
    tmpsum += v[ptr];
    ans1[ptr] = v[ptr];
    for (int i = ptr - 1; i >= 0; i--) {
      ans1[i] = min(ans1[i + 1], v[i]);
      tmpsum += ans1[i];
    }
    for (int i = ptr + 1; i < n; i++) {
      ans1[i] = min(ans1[i - 1], v[i]);
      tmpsum += ans1[i];
    }
    if (tmpsum > sum) {
      sum = tmpsum;
      for (int i = 0; i < n; i++) {
        ans[i] = ans1[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
