#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  int a[n];
  priority_queue<int> pq;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    pq.push(temp);
    a[i] = temp;
  }
  for (int i = 0; i < n; i++) {
    if (pq.top() == a[i]) {
      priority_queue<int> pq2 = pq;
      pq2.pop();
      cout << pq2.top() << endl;
    } else {
      cout << pq.top() << endl;
    }
  }
}
