#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, d;
  cin >> n;
  vector<int> a;
  vector<int> b;
  for (int i = 0; i < n; i++) {
    cin >> d;
    a.push_back(d);
    b.push_back(d);
  }
  for (int i = 0; i < n; i++) {
    a[i] = -1;
    sort(a.begin(), a.end());
    cout << a[n - 1] << endl;
    a = b;
  }
  return 0;
}
