#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, mx = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a = vec.at(j);
      if (mx < a && vec.at(i) != a) mx = a;
    }
    cout << a << endl;
  }
}
