#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T poww(T b, T p) {
  long long a = 1;
  while (p) {
    if (p & 1) {
      a = (a * b);
    }
    p >>= 1;
    b = (b * b);
  }
  return a;
}
template <class T>
inline T gcd(T a, T b) {
  if (b > a) return gcd(b, a);
  return ((b == 0) ? a : gcd(b, a % b));
}
set<pair<int, int> > st;
int child[100001];
int main() {
  int i, j, k, n;
  cin >> n;
  set<pair<int, int> >::iterator it, it2;
  for ((i) = 0; (i) < (n); (i)++) {
    scanf("%d", &j);
    if (i) {
      it = st.lower_bound(make_pair(j, -1));
      if (it == st.begin()) {
        printf("%d ", (*it).first);
        child[(*it).second] |= 1;
      } else if (it == st.end()) {
        it--;
        printf("%d ", (*it).first);
        child[(*it).second] |= 2;
      } else {
        it2 = it;
        std::advance(it2, -1);
        pair<int, int> l = *it2;
        pair<int, int> r = *it;
        if (child[l.second] < 2 && (child[r.second] & 1) == 0) {
          assert(false);
        } else if (child[l.second] < 2) {
          printf("%d ", l.first);
          child[l.second] |= 2;
        } else if ((child[r.second] & 1) == 0) {
          printf("%d ", r.first);
          child[r.second] |= 1;
        } else {
          assert(false);
        }
      }
    }
    st.insert(make_pair(j, i));
  }
}
