#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int skip_i = 0; skip_i < n; ++skip_i) {
    int max_a = 0;
    for (int a_i = 0; a_i < n; ++a_i) {
      if (a_i == skip_i) continue;
      max_a = max(max_a, a[a_i]);
    }
    cout << max_a << endl;
  }
  return 0;
}
