#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
int n, a[maxn], c[maxn], ans[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[i] = a[i];
  }
  int k = n - 1;
  int temp;
  for (int i = 0; i < n; i++) {
    temp = c[i];
    c[i] = 0;
    nth_element(c, c + k, c + n);
    cout << c[k] << endl;
    for (int j = 0; j < n; j++) {
      c[j] = a[j];
    }
    c[i] = temp;
  }
  return 0;
}
