#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  vector<int> a;
  vector<int> b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
    b.push_back(tmp);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    int ans = a[n - 1];
    if (a[n - 1] == b[i]) {
      ans = a[n - 2];
    }
    cout << ans << endl;
  }
}
