#include <bits/stdc++.h>
using namespace std;
set<int> s;
map<int, int> ls, rs;
int n, x;
int main() {
  cin >> n >> x;
  s.insert(x);
  for (int i = 1; i < n; i++) {
    cin >> x;
    set<int>::iterator it = s.lower_bound(x);
    if (it == s.end()) {
      it--;
      rs[*it] = x;
      cout << *it << ' ';
    } else if (ls[*it] == 0) {
      ls[*it] = x;
      cout << *it << ' ';
    } else {
      it--;
      rs[*it] = x;
      cout << *it << ' ';
    }
    s.insert(x);
  }
  cout << endl;
}
