#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
int N;
int a[100001];
int parent[100001];
map<int, int> used;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &a[i]);
  set<int> ck;
  ck.insert(a[0]);
  for (int i = 1; i < N; i++) {
    auto lo = ck.lower_bound(a[i]);
    if (lo == ck.end()) lo--;
    if (*lo > a[i] && used[*lo])
      lo--;
    else if (*lo > a[i])
      used[*lo] = 1;
    parent[i] = *lo;
    ck.insert(a[i]);
  }
  for (int i = 1; i < N; i++) printf("%d ", parent[i]);
  return 0;
}
