#include <bits/stdc++.h>
using namespace std;
int main() {
  int T = 1, qq = 0;
  while (T--) {
    long long int n, x, y, a, b, c, i, j, k, inc = 0, dec = 0;
    long long int mx = 0LL;
    cin >> n;
    long long int aa[n + 1][n + 1], mm[n + 1];
    for (i = 1; i <= n; i++) scanf("%lld", &mm[i]);
    ;
    mm[0] = 0LL;
    for (i = 1; i <= n; i++) {
      x = i - 1, y = i + 1;
      k = mm[i];
      aa[i][i] = mm[i];
      while (x > 0) {
        if (mm[x] >= k)
          aa[i][x] = k;
        else
          aa[i][x] = mm[x], k = mm[x];
        x--;
      }
      k = mm[i];
      while (y <= n) {
        if (mm[y] >= k)
          aa[i][y] = k;
        else
          aa[i][y] = mm[y], k = mm[y];
        y++;
      }
      long long int kkk = 0;
      for (j = 1; j <= n; j++) kkk += aa[i][j];
      if (kkk > mx) mx = kkk;
      aa[i][0] = kkk;
    }
    for (i = 1; i <= n; i++) {
      if (mx == aa[i][0]) {
        for (j = 1; j <= n; j++) {
          cout << aa[i][j] << " ";
        }
        return 0;
      }
    }
  }
}
