#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005], sol[100005];
typedef struct node {
  int l, r;
} node;
node bst[100005];
void init() { return; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  init();
  cin >> n;
  set<int> present;
  set<int>::iterator it;
  int l, r;
  map<int, int> idx;
  for (int i = 0; i < n; i++) {
    l = -1, r = -1;
    cin >> a[i];
    idx[a[i]] = i;
    it = present.upper_bound(a[i]);
    if (it != present.begin()) {
      l = *(--it);
      it++;
    }
    if (it != present.end()) {
      r = *it;
    }
    if (l != -1 && bst[idx[l]].r == -1) {
      bst[idx[l]].r = i;
      sol[i] = l;
    } else if (r != -1 && bst[idx[r]].l == -1) {
      bst[idx[r]].l = i;
      sol[i] = r;
    }
    bst[i].l = bst[i].r = -1;
    present.insert(a[i]);
  }
  for (int i = 1; i < n; i++) {
    cout << sol[i] << " ";
  }
  return 0;
}
