#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int counter, tmp, max, result;
  cin >> counter;
  for (int i = 0; i < counter; i++) {
    cin >> tmp;
    v.emplace_back(tmp);
  }
  for (int i = 0; i < counter; i++) {
    result = 0;
    tmp = v[i];
    v[i] = 0;
    for (int j = 0; j < counter; j++) {
      if (v[j] <= result) {
        continue;
      }
      result = v[j];
    }
    cout << result << endl;
    v[i] = tmp;
  }
  return 0;
}
