#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
std ::map<int, int>::iterator x, l, s;
int main() {
  int n, p;
  cin >> n;
  mp[0] = 0;
  mp[1 << 30] = 0;
  for (int i = 0; i < n; i++) {
    cin >> p;
    x = mp.lower_bound(p);
    l = x--;
    s = x->second > l->second ? x : l;
    if (i) cout << s->first << " ";
    mp[p] = s->second + 1;
  }
}
