#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n;
  vector<int> a;
  set<pair<int, int>> s;
  set<pair<int, int>>::iterator it, it1;
  cin >> n >> j;
  a.push_back(j);
  s.insert(make_pair(j, 0));
  for (i = 1; i < n; i++) {
    cin >> j;
    a.push_back(j);
    it = s.upper_bound(make_pair(j, -1));
    if (it == s.begin()) {
      cout << a[it->second] << ' ';
    } else if (it == s.end()) {
      it--;
      cout << a[it->second] << ' ';
    } else {
      it1 = it;
      it--;
      if (it->second > it1->second)
        cout << a[it->second] << ' ';
      else
        cout << a[it1->second] << ' ';
    }
    s.insert(make_pair(j, i));
  }
}
