#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, tmp = 0;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  vector<int> memo(a);
  for (int i = 0; i < n; i++) {
    sort(memo.begin(), memo.end());
    if (memo[memo.size() - 1] > a[i])
      cout << memo[memo.size() - 1] << endl;
    else {
      for (int j = n - 1; j >= 0; j--) {
        if (memo[memo.size() - 1] == memo[j])
          continue;
        else {
          cout << memo[j] << endl;
          break;
        }
      }
    }
  }
}
