#include <bits/stdc++.h>
using namespace std;
struct gt {
 public:
  int a;
  int index;
  int parent;
  gt(int a, int i) : a(a), index(i) {}
  bool const operator<(const gt& b) const { return this->a < b.a; }
};
struct lo {
 public:
  int a;
  int index;
  int parent;
  lo(int a, int i) : a(a), index(i) {}
  bool const operator<(const lo& b) const { return this->a > b.a; }
};
bool haschild[100005];
int main() {
  int n;
  scanf("%d", &n);
  int x;
  vector<pair<int, int> > v(n);
  scanf("%d", &x);
  v[0] = make_pair(-1, x);
  set<lo> l;
  set<gt> g;
  l.insert(lo(x, 0));
  g.insert(gt(x, 0));
  for (int i = 1; i < n; i++) {
    scanf("%d", &x);
    set<gt>::iterator ig = g.upper_bound(gt(x, 0));
    if (ig == g.end() || haschild[ig->index]) {
      set<lo>::iterator il = l.upper_bound(lo(x, 0));
      v[i] = make_pair(il->index, x);
    } else {
      haschild[ig->index] = true;
      v[i] = make_pair(ig->index, x);
    }
    g.insert(gt(x, i));
    l.insert(lo(x, i));
  }
  for (int i = 1; i < n; i++) {
    printf("%d ", v[v[i].first].second);
  }
  puts("");
  return 0;
}
