#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int m[1010], tmp[1010][1010];
long long sum[1010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &m[i]);
  long long mx = 0;
  for (int i = 1; i <= n; i++) {
    tmp[i][i] = m[i];
    for (int j = i - 1; j >= 1; j--) tmp[i][j] = min(m[j], tmp[i][j + 1]);
    for (int j = i + 1; j <= n; j++) tmp[i][j] = min(m[j], tmp[i][j - 1]);
    for (int j = 1; j <= n; j++) sum[i] += tmp[i][j];
    mx = max(mx, sum[i]);
  }
  for (int i = 1; i <= n; i++)
    if (sum[i] == mx) {
      for (int j = 1; j <= n; j++) printf("%d ", tmp[i][j]);
      return 0;
    }
}
