#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a.at(i);
  vector<int> b = a;
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < (n); i++) {
    if (a.at(i) < b.at(0))
      cout << b.at(0) << endl;
    else {
      if (b.at(0) == b.at(1))
        cout << b.at(0) << endl;
      else
        cout << a.at(i) << b.at(1) << endl;
    }
  }
}
