#include <bits/stdc++.h>
using namespace std;
map<int, int> map1;
set<int> myset;
set<int>::iterator itlow;
int main() {
  int i, j, k, l, t, n;
  cin >> n;
  cin >> j;
  myset.insert(j);
  for (i = 2; i <= n; i++) {
    cin >> j;
    map1[j] = i;
    itlow = myset.lower_bound(j);
    if (itlow == myset.begin()) {
      k = *itlow;
      cout << k << " ";
      myset.insert(j);
      continue;
    }
    k = *itlow;
    l = *(--itlow);
    if (map1[l] >= map1[k])
      cout << l << " ";
    else
      cout << k << " ";
    myset.insert(j);
  }
  cout << endl;
}
