#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a, t;
  int max = 0;
  std::vector<int> A;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    A.push_back(a);
  }
  for (int i = 0; i < N; i++) {
    t = A[i];
    A.erase(A.begin() + i);
    max = *max_element(A.begin(), A.end());
    cout << max << endl;
    A.insert(A.begin() + i, t);
  }
  return 0;
}
