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