#include <bits/stdc++.h>
using namespace std;
long long n, m;
struct qwq {
  long long num;
  long long down;
} a[200000];
long long cmp(qwq a, qwq b) { return a.num > b.num; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].num;
    a[i].down = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i != a[j].down) {
        cout << a[j].num << endl;
        break;
      }
    }
  }
  return 0;
}
