#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  int val;
  mp[0] = 0;
  mp[1000000000] = 0;
  map<int, int>::iterator a;
  map<int, int>::iterator b;
  map<int, int>::iterator pos;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val);
    a = mp.lower_bound(val);
    b = a--;
    int x = a->second, y = b->second;
    if (x > y)
      pos = a;
    else
      pos = b;
    mp[val] = pos->second + 1;
    if (i != 1) printf("%d ", pos->first);
  }
  return 0;
}
