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