#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int inf = 1e9;
int n;
int nums[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }
  set<pair<int, pair<int, int> > > magic;
  magic.insert(
      pair<int, pair<int, int> >(inf + 1, pair<int, int>(nums[0] + 1, 1)));
  magic.insert(
      pair<int, pair<int, int> >(nums[0] - 1, pair<int, int>(-inf - 1, 0)));
  for (int i = 1; i < n; i++) {
    auto it = magic.lower_bound(pair<int, pair<int, int> >(
        nums[i], pair<int, int>(-inf - 1, -inf - 1)));
    int onde = (*it).second.second;
    pair<int, pair<int, int> > save = *it;
    magic.erase(it);
    int par = -1;
    if (onde) {
      par = save.second.first - 1;
      pair<int, pair<int, int> > esq =
          pair<int, pair<int, int> >(nums[i] - 1, pair<int, int>(par + 1, 0));
      magic.insert(esq);
      pair<int, pair<int, int> > dir = pair<int, pair<int, int> >(
          save.first, pair<int, int>(nums[i] + 1, 1));
      magic.insert(dir);
    } else {
      par = save.first + 1;
      pair<int, pair<int, int> > esq = pair<int, pair<int, int> >(
          nums[i] - 1, pair<int, int>(save.second.first, 0));
      magic.insert(esq);
      pair<int, pair<int, int> > dir =
          pair<int, pair<int, int> >(par - 1, pair<int, int>(nums[i] + 1, 1));
      magic.insert(dir);
    }
    cout << par << ' ';
  }
  return 0;
}
