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