#include <bits/stdc++.h>
using namespace std;
long long int n, a[100005];
set<long long int> cbst;
map<long long int, long long int> ltch, rtch, par;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n; ++i) cin >> a[i];
  cbst.insert(a[1]);
  for (long long int i = 2; i <= n; ++i) {
    set<long long int>::iterator pos = cbst.lower_bound(a[i]);
    if (pos == cbst.end()) {
      pos--;
      rtch.insert(make_pair(*pos, a[i]));
      par.insert(make_pair(a[i], *pos));
      cbst.insert(a[i]);
      continue;
    }
    if (pos == cbst.begin()) {
      ltch.insert(make_pair(*pos, a[i]));
      par.insert(make_pair(a[i], *pos));
      cbst.insert(a[i]);
      continue;
    }
    if (ltch.find(*pos) == ltch.end()) {
      ltch.insert(make_pair(*pos, a[i]));
      par.insert(make_pair(a[i], *pos));
      cbst.insert(a[i]);
      continue;
    } else {
      pos--;
      rtch.insert(make_pair(*pos, a[i]));
      par.insert(make_pair(a[i], *pos));
      cbst.insert(a[i]);
      continue;
    }
  }
  for (int i = 2; i <= n; ++i) cout << par[a[i]] << " ";
}
