#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  std::vector<int> array(N);
  for (int i = 0; i < N; ++i) {
    cin >> array[i];
  }
  for (int i = 0; i < N; ++i) {
    int max_value = 0;
    for (int j = 0; j < N; ++j) {
      if (i != j) {
        if (max_value < array[j]) {
          max_value = array[j];
        }
      }
    }
    cout << max_value << endl;
  }
  return 0;
}
