#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int t;
  cin >> n;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    cin >> t;
    a.push_back(t);
  }
  b = a;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (b[i] == a[n - 2])
      cout << a[n - 1] << "\n";
    else
      cout << a[n - 2] << "\n";
  }
}
