#include <bits/stdc++.h>
const double pi = 3.14159265358979323846;
using namespace std;
long long fastexp(long long a, long long b) {
  long long answer = 1;
  long long temp = a;
  while (b > 0) {
    if (b & 1) answer *= (temp);
    temp *= temp;
    b >>= 1;
  }
  return answer;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  ;
  long long* A = new long long[n];
  for (long long i = 0; i < n; i++) cin >> A[i];
  long long answer = 0;
  long long pivot = -1;
  for (long long i = 0; i < n; i++) {
    long long curr = A[i];
    long long temp = A[i];
    for (long long j = i - 1; j >= 0; j--) {
      if (A[j] < temp) {
        temp = A[j];
        curr += A[j];
      } else {
        curr += temp;
      }
    }
    temp = A[i];
    for (long long j = i + 1; j < n; j++) {
      if (A[j] < temp) {
        temp = A[j];
        curr += A[j];
      } else {
        curr += temp;
      }
    }
    if (answer < curr) {
      answer = curr;
      pivot = i;
    }
  }
  long long* Ans = new long long[n];
  Ans[pivot] = A[pivot];
  long long temp = Ans[pivot];
  for (long long i = pivot - 1; i >= 0; i--) {
    if (A[i] < temp) {
      temp = A[i];
      Ans[i] = A[i];
    } else {
      Ans[i] = temp;
    }
  }
  temp = A[pivot];
  for (long long i = pivot + 1; i < n; i++) {
    if (A[i] < temp) {
      temp = A[i];
      Ans[i] = temp;
    } else {
      Ans[i] = temp;
    }
  }
  for (long long i = 0; i < n; i++) cout << Ans[i] << " ";
  return 0;
}
