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