#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    int max = (i == 0 ? 1 : 0);
    for (int j = (i == 0 ? 1 : 0); j < n; ++j) {
      if (j != i) {
        if (a[max] < a[j]) {
          max = j;
        }
      }
    }
    cout << a[max] << endl;
  }
  return 0;
}
