#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  scanf("%d %d", &n, &a);
  set<int> s, left, right;
  s.insert(a);
  for (int i = 0; i + 1 < n; ++i) {
    int a;
    scanf("%d", &a);
    auto p = s.upper_bound(a);
    int parent = -1;
    if (p != s.end() && !right.count(*p)) {
      parent = *p;
      right.insert(*p);
    } else {
      --p;
      parent = *p;
      left.insert(*p);
    }
    s.insert(a);
    printf("%d%c", parent, " \n"[i + 2 == n]);
  }
}
