#include <bits/stdc++.h>
using namespace std;
int a[1005], b[1005][1005];
long long cnt[1005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long maxx = 0;
  int maxi;
  for (int k = 0; k < n; k++) {
    int temp = k;
    b[k][k] = a[k];
    cnt[k] += b[k][k];
    for (int i = k + 1; i < n; i++)
      b[k][i] = (a[i] > b[k][i - 1] ? b[k][i - 1] : a[i]), cnt[k] += b[k][i];
    for (int i = k - 1; i >= 0; i--)
      b[k][i] = (a[i] > b[k][i + 1] ? b[k][i + 1] : a[i]), cnt[k] += b[k][i];
    if (cnt[k] > maxx) maxx = cnt[k], maxi = k;
  }
  for (int i = 0; i < n; i++) cout << b[maxi][i] << (i == n - 1 ? "\n" : " ");
  return 0;
}
