#include <bits/stdc++.h>
using namespace std;
set<long long> s;
set<long long>::iterator it;
map<long long, long long> rt, lt;
long long a[200000];
int main() {
  long long n, i, temp;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  s.insert(a[0]);
  for (i = 1; i < n; i++) {
    it = s.upper_bound(a[i]);
    if (it == s.end()) {
      it--;
      cout << *it << " ";
      rt[*it] = a[i];
    } else {
      temp = *it;
      while (lt[temp]) {
        temp = lt[temp];
        if (temp < a[i]) break;
      }
      if (temp < a[i]) {
        while (rt[temp]) {
          temp = rt[temp];
        }
        rt[temp] = a[i];
        cout << temp << " ";
      } else {
        cout << temp << " ";
        lt[temp] = a[i];
      }
    }
    s.insert(a[i]);
  }
  return 0;
}
