#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> t;
  t = a;
  sort(a.begin(), a.end(), greater<int>());
  a.erase(unique(a.begin(), a.end()), a.end());
  for (int i = 0; i < n; ++i) {
    if (t[i] == a[0]) {
      cout << a[1] << endl;
    } else {
      cout << a[0] << endl;
    }
  }
  return 0;
}
