#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n >> a;
  map<int, int> L;
  map<int, int> R;
  set<int> tree;
  tree.insert(a);
  for (int i = 0; i < n - 1; i++) {
    int ans;
    cin >> a;
    set<int>::iterator fi = tree.upper_bound(a);
    if (fi != tree.end() && L.count(*fi) == 0) {
      L[*fi] = a;
      ans = *fi;
    } else {
      fi--;
      R[*fi] = a;
      ans = *fi;
    }
    tree.insert(a);
    printf("%d%c", ans, i == n - 2 ? '\n' : ' ');
  }
  return 0;
}
