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