#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
struct node {
  bool esq, dir;
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, x;
  cin >> n;
  long long root;
  cin >> root;
  set<long long> l, r;
  map<long long, node> m;
  for (long long i = 1; i < n; i++) {
    cin >> x;
    if (x > root) {
      if (r.size() == 0) {
        r.insert(x);
        cout << root << " ";
      } else {
        auto left = r.lower_bound(x);
        auto right = left--;
        long long resp;
        if (right == r.end()) {
          resp = *left;
          m[*left].dir = true;
        } else {
          if (m[*right].esq) {
            resp = *left;
            m[*left].dir = true;
          } else {
            resp = *right;
            m[*right].esq = true;
          }
        }
        cout << resp << " ";
        r.insert(x);
      }
    } else {
      if (l.size() == 0) {
        l.insert(x);
        cout << root << " ";
      } else {
        auto left = l.lower_bound(x);
        auto right = left--;
        long long resp;
        if (right == l.end()) {
          resp = *left;
          m[*left].dir = true;
        } else {
          if (m[*right].esq) {
            resp = *left;
            m[*left].dir = true;
          } else {
            resp = *right;
            m[*right].esq = true;
          }
        }
        cout << resp << " ";
        l.insert(x);
      }
    }
  }
  cout << "\n";
}
