#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, i, j, m;
  cin >> N;
  int A[N];
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (i = N - 2; i >= 0; i--) {
    for (j = N - 1; j > i; j--) {
      m = max(A[i], A[j]);
      cout << m << endl;
    }
  }
  return 0;
}
