#include <bits/stdc++.h>
using namespace std;
set<int> s;
map<int, int> ls, rs;
int x;
int main() {
  int n;
  scanf("%d", &n);
  scanf("%d", &x);
  s.insert(x);
  set<int>::iterator it;
  for (int i = 1; i < n; i++) {
    scanf("%d", &x);
    it = s.lower_bound(x);
    if (it == s.end()) {
      it--;
      rs[*it] = x;
      printf("%d ", *it);
    } else if (ls[*it] == 0) {
      ls[*it] = x;
      printf("%d ", *it);
    } else {
      it--;
      rs[*it] = x;
      printf("%d ", *it);
    }
    s.insert(x);
  }
  printf("\n");
}
