#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1ll;
  while (b > 0) {
    if (b % 2 != 0) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return res;
}
long long ncr(long long n, long long k) {
  if (k > n - k) k = n - k;
  long long pro = 1;
  for (long long i = 0; i < k; i++) {
    pro = (pro * (n - i)) % 1000000007;
    pro /= (i + 1);
  }
  return (pro % 1000000007);
}
vector<long long> prime;
void seive() {
  vector<bool> isprime(2000001, true);
  for (int i = 2; i * i <= 2000000; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= 2000000; j += i) {
        isprime[j] = false;
      }
    }
  }
  for (int i = 2; i <= 1000000; i++) {
    if (isprime[i]) prime.push_back(i);
  }
}
void swap(long long *a, long long *b) {
  long long temp = *a;
  *a = *b;
  *b = temp;
}
vector<long long> intersection(vector<long long> a, vector<long long> b) {
  int i = 0, j = 0;
  vector<long long> x;
  while (i < a.size() && j < b.size()) {
    if (a[i] == b[j]) {
      x.push_back(a[i]);
      i++;
      j++;
    } else if (a[i] < b[j]) {
      i++;
    } else
      j++;
  }
  return x;
}
void func(vector<long long> &arr, long long n) {
  vector<long long> dp(n);
  vector<long long> ans(n);
  long long maxx = INT_MIN;
  for (int i = 0; i < n; i++) {
    long long x = arr[i];
    int l = i - 1;
    int r = i + 1;
    long long count = arr[i];
    dp[i] = arr[i];
    while (l >= 0) {
      dp[l] = min(dp[l + 1], arr[l]);
      count += dp[l];
      l--;
    }
    while (r < n) {
      dp[r] = min(dp[r - 1], arr[r]);
      count += dp[r];
      r++;
    }
    if (count > maxx) {
      maxx = count;
      ans = dp;
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  func(arr, n);
  return 0;
}
