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