#include <bits/stdc++.h>
using namespace std;
long long int m, n, c, d, j, k, l, r, x, t, y, u, b, z, i, e, f, g, h;
int main() {
  int n;
  vector<int> v, ans;
  long long m = -1, h;
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    vector<int> a = v;
    h = 0;
    for (int j = i + 1; j < n; j++) a[j] = min(a[j], a[j - 1]);
    for (int j = i - 1; j >= 0; j--) a[j] = min(a[j], a[j + 1]);
    for (int j = 0; j < n; j++) h += a[j];
    if (h > m) {
      m = h;
      ans = a;
    }
  }
  for (int x : ans) cout << x << " ";
}
