#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 10007;
const int maxn = 1e6 + 5;
const double PI = acos(-1.0);
const double E = 2.718281828459;
const double eps = 1e-7;
int b[maxn], c[maxn];
int main() {
  int n;
  cin >> n;
  int a[maxn];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long res = b[i];
    for (int j = i - 1; j >= 0; j--) {
      if (b[j] > b[j + 1]) b[j] = b[j + 1];
      res += b[j];
    }
    for (int j = i + 1; j < n; j++) {
      if (b[j] > b[j - 1]) b[j] = b[j - 1];
      res += b[j];
    }
    if (res > ans) {
      ans = res;
      for (int i = 0; i < n; i++) c[i] = b[i];
    }
    for (int i = 0; i < n; i++) b[i] = a[i];
  }
  for (int i = 0; i < n; i++) cout << c[i] << " ";
  return 0;
}
