#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];
  }
  for (int64_t i = 0; i < N; i++) {
    int64_t M = 0;
    for (int64_t j = 0; j < i; j++) {
      M = max(M, A[j]);
    }
    for (int64_t j = i + 1; j < N; j++) {
      M = max(M, A[j]);
    }
    cout << M << endl;
  }
}
