#include <bits/stdc++.h>
using namespace std;
int main() {
  set<pair<pair<int, int>, int> > first;
  set<pair<pair<int, int>, int> >::iterator it;
  int i, j, k, n, m, x, y, z;
  cin >> n;
  first.insert(make_pair(make_pair(1, 1000000007), 0));
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    it = first.upper_bound(make_pair(make_pair(x, 1000000007), 1000000007));
    it--;
    if (i != 1) printf("%d ", it->second);
    pair<pair<int, int>, int> p = *it;
    first.erase(it);
    first.insert(make_pair(make_pair(p.first.first, x - 1), x));
    first.insert(make_pair(make_pair(x + 1, p.first.second), x));
  }
}
