#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k;
  cin >> n;
  vector<int> a(n);
  priority_queue<int> que;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (i = 0; i < n; ++i) {
    for (k = 0; k < n; ++k) {
      if (i == k) {
        continue;
      }
      que.push(a[k]);
    }
    cout << que.top() << endl;
    while (!que.empty()) que.pop();
  }
  return 0;
}
