#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  set<int> numbers;
  map<int, int> left;
  map<int, int> right;
  int n, v;
  cin >> n >> v;
  numbers.insert(-inf);
  numbers.insert(inf);
  left[-inf] = 1;
  left[inf] = 1;
  right[-inf] = 1;
  right[inf] = 1;
  numbers.insert(v);
  for (int i = 0; i < n - 1; i++) {
    cin >> v;
    auto it = numbers.upper_bound(v);
    set<int>::iterator it2 = it;
    it2--;
    int l = (*it2), r = (*it);
    int result;
    if (it != numbers.end() && left.count(*it) == 0) {
      left[*it] = v;
      result = *it;
    } else {
      it--;
      right[*it] = v;
      result = *it;
    }
    numbers.insert(v);
    cout << result;
    cout << ' ';
  }
}
