#include <bits/stdc++.h>
using namespace std;
int dx[] = {+1, -1, 0, 0};
int dy[] = {0, 0, +1, -1};
int dx2[] = {+1, -1, 0, 0, +1, +1, -1, -1};
int dy2[] = {0, 0, +1, -1, +1, -1, -1, +1};
inline long long squ(long long x) { return (x * x); }
inline long long power(long long bs, long long k) {
  long long x = 1LL, y = bs;
  if (k == 0) return 1LL;
  while (k > 0) {
    if (k % 2) x *= y;
    y *= y;
    k /= 2;
  }
  return x;
}
int a[100100], n, pr[100100];
pair<int, int> cld[100100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.unsetf(ios::floatfield);
  cout.precision(6);
  cout.setf(ios::fixed, ios::floatfield);
  ;
  int i, j;
  cin >> n;
  set<int> st;
  cin >> j;
  st.insert(j);
  map<int, int> mp;
  mp[j] = 0;
  for (i = 0; i < n; i++) {
    cld[i].first = -1;
    cld[i].second = -1;
  }
  for (i = 1; i < n; i++) {
    cin >> a[i];
    mp[a[i]] = i;
    st.insert(a[i]);
    auto it = st.find(a[i]);
    if (it != st.begin()) {
      it--;
      if (cld[mp[*it]].second == -1) {
        cld[mp[*it]].second = a[i];
        pr[i] = *it;
      } else {
        it++;
        it++;
        if (cld[mp[*it]].first == -1) {
          cld[mp[*it]].first = a[i];
          pr[i] = *it;
        }
      }
      continue;
    }
    it++;
    cld[mp[*it]].first = a[i];
    pr[i] = *it;
  }
  for (i = 1; i < n; i++) cout << pr[i] << ' ';
  return 0;
}
