#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) B.at(i) = A.at(i);
  for (int i = 0; i < N; i++) {
    int right = 0;
    int left = 0;
    for (int j = 0; j < i; j++) right = max(right, A.at(j));
    for (int k = N - 1; k > i; k--) left = max(left, A.at(k));
    int ans = max(right, left);
    cout << ans << endl;
  }
}
