#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int INF = 0x3f3f3f3f;
int n;
int a[maxn], minh[maxn];
int h[maxn];
long long s, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int high = 1; high <= n; ++high) {
    s = 0;
    minh[high] = a[high];
    for (int i = high - 1; i >= 1; --i) minh[i] = min(minh[i + 1], a[i]);
    for (int i = high + 1; i <= n; ++i) minh[i] = min(minh[i - 1], a[i]);
    for (int i = 1; i <= n; ++i) s += minh[i];
    if (s >= ans) {
      ans = s;
      for (int i = 1; i <= n; ++i) h[i] = minh[i];
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", h[i]);
}
