#include <bits/stdc++.h>
using namespace std;
long const N = 100020;
long parent[N];
map<long long, pair<bool, bool> > children;
int main() {
  set<long long> SET;
  set<long long>::iterator it;
  long long n, in;
  cin >> n;
  cin >> in;
  SET.insert(in);
  for (long i = 1; i < n; i++) {
    cin >> in;
    it = SET.upper_bound(in);
    if (it == SET.end()) {
      parent[i] = *(--it);
      children[parent[i]].second = true;
    } else {
      if (children[*it].first == false) {
        parent[i] = *it;
        children[parent[i]].first = true;
      } else {
        parent[i] = *(--it);
        children[parent[i]].second = true;
      }
    }
    SET.insert(in);
  }
  for (long i = 1; i <= n; i++) {
    if (parent[i] != 0) {
      cout << parent[i] << " ";
    }
  }
  return 0;
}
