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