#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s;
set<pair<int, int> >::iterator ii;
int a[100010], mx[100010], mn[100010], n, t1, t2;
bool l[100010], r[100010];
int main() {
  scanf("%d", &n);
  scanf("%d", &a[1]);
  s.insert(make_pair(0, 0));
  s.insert(make_pair((int)1e9 + 1, 0));
  s.insert(make_pair(a[1], 1));
  mn[1] = 0;
  mx[1] = (int)1e9 + 1;
  for (int i = 2; i <= n; i++) {
    scanf("%d", a + i);
    ii = s.upper_bound(make_pair(a[i], i));
    t1 = ii->second;
    ii--;
    t2 = ii->second;
    if (!t1 || a[i] < mn[t1] || a[i] >= mx[t1] || l[t1]) {
      printf("%d ", a[t2]);
      mn[i] = max(mn[t2], a[t2]);
      mx[i] = mx[t2];
      r[t2] = 1;
    } else {
      printf("%d ", a[t1]);
      mn[i] = mn[t1];
      mx[i] = min(mx[t1], a[t1]);
      l[t1] = 1;
    }
    s.insert(make_pair(a[i], i));
  }
  return 0;
}
