#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
map<int, int>::iterator it, it1, itend;
int pr[100100], a[100100], i, n;
void add(int x) {
  int t;
  it1 = m.upper_bound(x);
  it = it1;
  it--;
  itend = m.end();
  itend--;
  if (it == m.end()) {
    pr[i] = m.begin()->first;
    t = m.begin()->second + 1;
    m[x] = t;
  } else if (it1 == m.end()) {
    pr[i] = itend->first;
    m[x] = itend->second + 1;
  } else if (it->second > it1->second) {
    pr[i] = it->first;
    m[x] = it->second + 1;
  } else {
    pr[i] = it1->first;
    m[x] = it1->second + 1;
  }
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i == 0)
      m[a[i]] = 0;
    else
      add(a[i]);
  }
  for (i = 1; i < n; i++) printf("%d ", pr[i]);
  printf("\n");
  return 0;
}
