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