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