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