#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  long long par;
  cin >> n;
  map<long long, long long> left;
  map<long long, long long> right;
  map<long long, long long>::iterator l, r;
  set<long long> s;
  set<long long>::iterator it;
  long long x;
  cin >> x;
  s.insert(x);
  for (i = 2; i <= n; i++) {
    cin >> x;
    it = s.upper_bound(x);
    if (it != s.end() && left[*it] == 0) {
      par = *it;
      left[*it] = 1;
    } else {
      it--;
      par = *it;
      right[*it] = 1;
    }
    s.insert(x);
    cout << par << " ";
  }
  cout << endl;
}
