#include <bits/stdc++.h>
using namespace std;
map<long long, bool> l, r;
map<long long, long long> par;
set<long long> BST;
long long a[1000007];
int main() {
  set<long long>::iterator now, pre;
  long long N;
  scanf("%lld", &N);
  for (long long i = (0); i < (N); i++) {
    scanf("%lld", &a[i]);
    if (!BST.empty()) {
      now = BST.upper_bound(a[i]);
      pre = now;
      pre--;
      if (now == BST.end()) {
        r[*pre] = true;
        par[a[i]] = *pre;
      } else if (now == BST.begin()) {
        l[*now] = true;
        par[a[i]] = *now;
      } else if (l.find(*now) == l.end()) {
        l[*now] = true;
        par[a[i]] = *now;
      } else {
        r[*pre] = true;
        par[a[i]] = *pre;
      }
    }
    BST.insert(a[i]);
  }
  for (long long i = (1); i < (N); i++) printf("%lld ", par[a[i]]);
}
