#include <bits/stdc++.h>
using namespace std;
int n;
int a[100001];
struct node {
  int id;
  node *child[2];
};
map<int, node *> m;
map<int, int> par;
void consttree(node *tmp, int a);
int main() {
  set<int> s;
  set<int>::iterator it;
  cin >> n;
  cin >> a[1];
  s.insert(a[1]);
  node start = {a[1], {NULL, NULL}};
  m[a[1]] = &start;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    it = s.lower_bound(a[i]);
    if (it == s.end()) it--;
    consttree(m[*it], a[i]);
    s.insert(a[i]);
  }
  for (int i = 2; i <= n; i++) cout << par[a[i]] << " ";
}
void consttree(node *tmp, int a) {
  if (a < tmp->id) {
    if (tmp->child[0] == NULL) {
      node *newnode;
      newnode = new node;
      newnode->id = a;
      newnode->child[0] = NULL;
      newnode->child[1] = NULL;
      m[a] = newnode;
      par[a] = tmp->id;
      tmp->child[0] = newnode;
    } else
      consttree(tmp->child[0], a);
  } else {
    if (tmp->child[1] == NULL) {
      node *newnode;
      newnode = new node;
      newnode->id = a;
      newnode->child[0] = NULL;
      newnode->child[1] = NULL;
      m[a] = newnode;
      par[a] = tmp->id;
      tmp->child[1] = newnode;
    } else
      consttree(tmp->child[1], a);
  }
}
