#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vecA(n);
  for (int i = 0; i < n; i++) cin >> vecA.at(i);
  priority_queue<int> qA;
  for (int i = 0; i < n; i++) qA.push(vecA[i]);
  vector<int> vecAns;
  for (int i = 0; i < n; i++) {
    priority_queue<int> qB = qA;
    if (qB.top() == vecA[i]) {
      qB.pop();
      vecAns.push_back(qB.top());
      continue;
    }
    vecAns.push_back(qB.top());
  }
  for (int i = 0; i < vecAns.size(); i++) cout << vecAns[i] << endl;
  return 0;
}
