#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> seq(n);
  for (int i = 0; i < n; i++) {
    cin >> seq.at(i);
  }
  vector<int> Max(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      Max.at(i) = max(seq.at(j), Max.at(i));
    }
    cout << Max.at(i) << endl;
  }
  return 0;
}
