#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 100000000;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t N;
  cin >> N;
  int64_t A[N + 1];
  for (int64_t i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64_t M[N + 1];
  for (int64_t i = 0; i < N; i++) {
    M[i] = 0;
  }
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = 0; j < i; j++) {
      M[i] = max(M[i], A[j]);
    }
    for (int64_t j = i + 1; j < N; j++) {
      M[i] = max(M[i], A[j]);
    }
  }
  for (int64_t i = 0; i < N; i++) {
    cout << M[i] << endl;
  }
}
