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