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