#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int arr[a], max = 0, ln = 0;
  for (int i = 0; i < a; ++i) {
    cin >> arr[i];
  }
  for (int i = 0; i < a; ++i) {
    max = 0;
    for (int i = 0; i < a; ++i) {
      if (i != ln && arr[i] > max) {
        max = arr[i];
      }
    }
    ln++;
    cout << max << endl;
  }
  return 0;
}
