#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
int n, a[MAX];
set<int> active;
map<int, int> h;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int(i) = (1); (i) < (n + 1); (i)++) cin >> a[i];
  active.insert(-((int)1e9 + 10));
  active.insert(((int)1e9 + 10));
  h[((int)1e9 + 10)] = -1;
  h[-((int)1e9 + 10)] = -1;
  h[a[1]] = 1;
  active.insert(a[1]);
  for (int(i) = (2); (i) < (n + 1); (i)++) {
    int cur = a[i];
    auto ind = active.upper_bound(cur);
    int r = *ind;
    int l = *(--ind);
    if (h[l] > h[r]) swap(l, r);
    cout << r << ' ';
    active.insert(cur);
    h[cur] = h[r] + 1;
  }
}
