#include <bits/stdc++.h>
using namespace std;
int a[200050];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  while (cin >> t) {
    for (int i = 0; i < t; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < t; i++) {
      priority_queue<int, vector<int>, less<int> > q;
      for (int j = 0; j < t; j++) {
        if (j == i)
          continue;
        else
          q.push(a[j]);
      }
      cout << q.top() << endl;
    }
  }
  return 0;
}
