#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int counter, tmp;
  cin >> counter;
  for (int i = 0; i < counter; i++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  for (int i = 0; i < counter; i++) {
    tmp = v[i];
    v[i] = 0;
    cout << *max_element(v.begin(), v.end()) << endl;
    v[i] = tmp;
  }
  return 0;
}
