#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1000000000000;
const double eps = (double)1e-8;
const int mod = (int)1000000007;
const int maxn = (int)1e5 + 5;
set<pair<int, int> > q;
set<pair<int, int> >::iterator it, it0, it1;
int n, a[maxn], o[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> a[i];
  }
  q.clear();
  q.insert(make_pair(a[1], 1));
  for (int i = (2); i <= (n); i++) {
    it = q.insert(make_pair(a[i], i)).first;
    if (it == q.begin())
      o[i] = (++q.begin())->first;
    else if (it == (--q.end())) {
      o[i] = (-- --q.end())->first;
    } else {
      it0 = it;
      it0--;
      it1 = it;
      it1++;
      if (it0->second > it1->second)
        o[i] = it0->first;
      else
        o[i] = it1->first;
    }
  }
  for (int i = (2); i <= (n); i++) {
    cout << o[i] << " ";
  }
  cout << "\n";
  return 0;
}
