#include <bits/stdc++.h>
using namespace std;
const int MAX_LEN = 1e5 + 1000;
int main() {
  int n;
  cin >> n;
  int root;
  scanf("%d", &root);
  set<pair<int, int> > tree;
  tree.insert(make_pair(root, 1));
  int num;
  int parent = 0;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &num);
    auto itr = tree.lower_bound(make_pair(num, i));
    if (itr == tree.end()) {
      itr--;
      parent = (itr)->first;
    } else if (itr == tree.begin()) {
      parent = (itr)->first;
    } else {
      auto suc = itr;
      auto pred = --itr;
      auto prn = ((suc->second) > (pred->second)) ? suc : pred;
      parent = prn->first;
    }
    tree.insert(make_pair(num, i));
    cout << parent << " ";
  }
  cout << endl;
  return 0;
}
