#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 10;
const long long INF = 1e18;
long long n, a[maxn], po, maxx = 0, m[maxn];
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> m[i];
    if (m[i] > maxx) {
      maxx = m[i];
      po = i;
    }
  }
  long long ans, maxx = 0;
  for (int po = 1; po <= n; po++) {
    long long sum = 0;
    a[po] = m[po];
    sum += a[po];
    for (int i = po - 1; i >= 1; i--) {
      a[i] = min(m[i], a[i + 1]);
      sum += a[i];
    }
    for (int i = po + 1; i <= n; i++) {
      a[i] = min(m[i], a[i - 1]);
      sum += a[i];
    }
    if (sum > maxx) {
      maxx = sum;
      ans = po;
    }
  }
  long long po = ans;
  a[po] = m[po];
  for (int i = po - 1; i >= 1; i--) {
    a[i] = min(m[i], a[i + 1]);
  }
  for (int i = po + 1; i <= n; i++) {
    a[i] = min(m[i], a[i - 1]);
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
