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