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