#include <bits/stdc++.h>
using namespace std;
template <class t>
t lcm(t a, t b) {
  return ((a * b) / __gcd(a, b));
}
const long long maxn = 1e5 + 5;
bool occupied[maxn][2];
map<long long, long long> numToPos;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  set<long long> s;
  set<long long>::iterator it;
  long long n, temp;
  cin >> n >> temp;
  s.insert(temp);
  for (long long i = 1; i < n; i++) {
    cin >> temp;
    numToPos[temp] = i;
    long long l, r;
    it = s.upper_bound(temp);
    if (it == s.end()) {
      it--;
      r = -1;
      l = *it;
    } else if (it == s.begin()) {
      l = -1;
      r = *it;
    } else {
      r = *it;
      it--;
      l = *it;
    }
    if (l == -1) {
      long long pos = numToPos[r];
      occupied[pos][0] = true;
      cout << r << " ";
    } else if (r == -1) {
      long long pos = numToPos[l];
      occupied[pos][1] = true;
      cout << l << " ";
    } else {
      long long lpos = numToPos[l], rpos = numToPos[r];
      if (occupied[lpos][1]) {
        occupied[rpos][0] = true;
        cout << r << " ";
      } else if (occupied[rpos][0]) {
        occupied[lpos][1] = true;
        cout << l << " ";
      } else {
        if (lpos < rpos) {
          cout << l << " ";
          occupied[lpos][1] = true;
        } else {
          cout << r << " ";
          occupied[rpos][0] = true;
        }
      }
    }
    s.insert(temp);
  }
  return 0;
}
