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