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