#include <bits/stdc++.h>
using namespace std;
mt19937_64 rd(time(0));
template <typename T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <typename T>
T max(T a, T b, T c, T d) {
  return max(a, max(b, c, d));
}
template <typename T>
T i_rand(T l, T r) {
  assert(l <= r);
  return uniform_int_distribution<T>(l, r)(rd);
}
template <typename T>
T r_rand(T l, T r) {
  return uniform_real_distribution<T>(l, r)(rd);
}
template <typename T>
void sfe(T a[], int l, int r) {
  shuffle(a + l, a + 1 + r, rd);
}
template <typename T>
void sfe(vector<T> a) {
  shuffle(a.begin(), a.end(), rd);
}
int n;
const long long _INF = -1e10;
const long long INF_ = 1e10;
map<long long, long long> d;
map<long long, long long> root;
signed main() {
  clock_t _, __;
  _ = clock();
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  set<long long> s;
  cin >> n;
  long long a;
  cin >> a;
  s.insert(_INF);
  d[_INF] = a - 1;
  root[_INF] = a;
  s.insert(a);
  d[a] = INF_;
  root[a] = a;
  for (int i = 2; i <= n; ++i) {
    cin >> a;
    long long l = *--s.upper_bound(a);
    long long r = d[l];
    cout << root[l] << ' ';
    root[l] = a;
    root[a] = a;
    s.insert(l);
    d[l] = a - 1;
    s.insert(a);
    d[a] = r;
  }
  __ = clock();
  double ___ = double(__ - _) / (double)CLOCKS_PER_SEC;
  cerr << "\nTime executed: " << setprecision(5) << fixed << ___ << " sec\n";
  return 0;
}
