#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int counta = 0;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  for (int i = 0; i < N; i++) {
    counta = 0;
    for (int y = 0; y < N; y++) {
      if (i != y) {
        if (data[counta] <= data[y]) {
          counta = y;
        }
      }
    }
    cout << data[counta] << endl;
  }
}
