#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int man = 2e5 + 10;
template <typename T>
inline T read() {
  T sum = 0, fl = 1;
  int ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fl = -1;
  for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0';
  return sum * fl;
}
template <typename T>
inline void write(T x) {
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
}
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T exgcd(T a, T b, T &g, T &x, T &y) {
  if (!b) {
    g = a, x = 1, y = 0;
  } else {
    exgcd(b, a % b, g, y, x);
    y -= x * (a / b);
  }
}
const long long mod = 1e9 + 7;
int a[man];
int res[man], tp[man];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long sum = a[i];
    int minn = a[i];
    tp[i] = a[i];
    for (int j = i - 1; j >= 1; j--) {
      minn = min(minn, a[j]);
      tp[j] = minn;
      sum += minn;
    }
    minn = a[i];
    for (int j = i + 1; j <= n; j++) {
      minn = min(minn, a[j]);
      tp[j] = minn;
      sum += minn;
    }
    if (sum > ans) {
      ans = sum;
      for (int j = 1; j <= n; j++) {
        res[j] = tp[j];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf(i == n ? "%d\n" : "%d ", res[i]);
  }
  return 0;
}
