#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (cin >> n) {
    long long arr[n];
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
    }
    long long topChoose[n];
    for (long long top = 0; top < n; top++) {
      long long cnt = 0;
      long long curr = arr[top];
      for (long long i = top + 1; i < n; i++) {
        if (arr[i] > curr) {
          cnt += curr;
        } else {
          cnt += arr[i];
          curr = arr[i];
        }
      }
      curr = arr[top];
      for (long long i = top; i >= 0; i--) {
        if (arr[i] > curr) {
          cnt += curr;
        } else {
          cnt += arr[i];
          curr = arr[i];
        }
      }
      topChoose[top] = cnt;
    }
    long long rightTop = 0;
    for (long long i = 0; i < n; i++) {
      if (topChoose[i] > topChoose[rightTop]) {
        rightTop = i;
      }
    }
    long long ans[n];
    long long curr = arr[rightTop];
    for (long long i = rightTop; i < n; i++) {
      curr = min(arr[i], curr);
      ans[i] = curr;
    }
    curr = arr[rightTop];
    for (long long i = rightTop - 1; i >= 0; i--) {
      curr = min(arr[i], curr);
      ans[i] = curr;
    }
    for (long long i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
}
