#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N - 1);
  int count = 0;
  int a;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    a = A[0];
    A.erase(A.begin());
    memcpy(&B, &A, sizeof(A));
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    cout << B[0] << endl;
    A.push_back(a);
  }
}
