#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  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());
    for (int j = 0; j < N - 1; j++) {
      count = max(count, A[j]);
    }
    A.push_back(a);
    cout << count << endl;
    count = 0;
  }
}
