#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, max = 0;
  cin >> n;
  vector<int> num(n);
  for (int i = 0; i < n; ++i) cin >> num.at(i);
  for (int i = 0; i < n; ++i) {
    for (int ii = 0; ii < n; ++ii) {
      if (ii != i && max < num.at(ii)) max = num.at(ii);
    }
    cout << max << endl;
    max = 0;
  }
}
