#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5, N = 1e5 + 20;
int arr[N], rnk[N], n, lazy[4 * N], seg[4 * N], l[N], r[N];
void apply(int idx) {
  if (lazy[idx] == -1) return;
  lazy[idx * 2] = lazy[idx * 2 + 1] = seg[idx * 2] = seg[idx * 2 + 1] =
      lazy[idx];
  lazy[idx] = -1;
}
void Put(int l, int r, int idx, int ql, int qr, int qidx) {
  if (qr < l || r < ql) return;
  if (ql <= l && r <= qr) {
    lazy[idx] = qidx;
    seg[idx] = qidx;
    return;
  }
  apply(idx);
  int mid = (l + r) / 2;
  Put(l, mid, idx * 2, ql, qr, qidx);
  Put(mid + 1, r, idx * 2 + 1, ql, qr, qidx);
}
int Get(int l, int r, int idx, int val) {
  if (val < l || r < val) return -1;
  if (l == r) return seg[idx];
  apply(idx);
  int mid = (l + r) / 2;
  return max(Get(l, mid, idx * 2, val), Get(mid + 1, r, idx * 2 + 1, val));
}
int add(int val, int idx) {
  int par = Get(0, MAX, 1, val);
  int parVal = lower_bound(rnk, rnk + n, arr[par]) - rnk;
  if (parVal < val) {
    Put(0, MAX, 1, parVal, val, idx);
    Put(0, MAX, 1, val, r[par], idx);
    l[idx] = parVal;
    r[idx] = r[par];
  } else {
    Put(0, MAX, 1, l[par], val, idx);
    Put(0, MAX, 1, val, parVal, idx);
    l[idx] = l[par];
    r[idx] = parVal;
  }
  return par;
}
int main() {
  memset(lazy, -1, sizeof lazy);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    rnk[i] = arr[i];
  }
  sort(rnk, rnk + n);
  Put(0, MAX, 1, 0, MAX - 1, 0);
  l[0] = 0, r[0] = MAX - 1;
  for (int i = 1; i < n; i++) {
    int val = lower_bound(rnk, rnk + n, arr[i]) - rnk;
    printf("%d ", arr[add(val, i)]);
  }
  return 0;
}
