#include <bits/stdc++.h>
using namespace std;
void max(int i, int n, vector<long long int> v) {
  v[i] = 0;
  sort(v.begin(), v.end());
  cout << v[n - 1] << endl;
}
int main() {
  long long int n = 0;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i) {
    max(i, n, v);
  }
  return 0;
}
