#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int a[N + 1];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m = -1;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    a[arr[i]]++;
    m = max(m, arr[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = m; j >= 0; j--) {
      if ((arr[i] != j && a[j])) {
        cout << j;
        break;
      }
    }
    cout << "\n";
  }
  return 0;
}
