#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, *A, *B;
  cin >> N;
  A = new int[N];
  B = new int[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    copy(A, A + N, B);
    B[i] = 0;
    stable_sort(B, B + N);
    cout << B[N - 1] << endl;
  }
  delete A, B;
  return 0;
}
