#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    swap(v.at(i), v.at(n - 1));
    int max = *max_element(v.begin(), v.end() - 1);
    cout << max << "\n";
    swap(v.at(i), v.at(n - 1));
  }
  return 0;
}
