#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  int max_1 = 0;
  for (int i = 0; i < (n); i++) {
    max_1 = max(max_1, a[i]);
  }
  for (int i = 0; i < (n); i++) {
    if (max_1 == a[i]) {
      int max_2 = 0;
      for (int j = 0; j < (n); j++) {
        if (i != j) max_2 = max(max_2, a[j]);
      }
      cout << max_2 << endl;
    } else
      cout << max_1 << endl;
  }
}
