#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> v;
  for (int i = 0; i < n; i++) v.push_back(a[i]);
  for (int i = 0; i < n; i++) {
    int t = a[i];
    a[i] = 0;
    int maxj = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] > a[maxj]) maxj = j;
    }
    cout << a[maxj] << endl;
    a[i] = t;
  }
  return;
}
int main() {
  solve();
  return 0;
}
