#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  cin >> num;
  vector<int> list;
  for (int idx = 0; idx < num; ++idx) {
    int ret;
    cin >> ret;
    list.push_back(ret);
  }
  for (int idx = 0; idx < num; ++idx) {
    int ret = 0;
    for (int idx2 = 0; idx2 < num; ++idx2) {
      if (idx != idx2 && list[idx2] > ret) {
        ret = list[idx2];
      }
    }
    cout << ret << endl;
  }
}
