#include <bits/stdc++.h>
using namespace std;
const int tmax = 1e5 + 5;
int n, a[tmax];
map<int, int> MM;
set<int> SET;
set<int>::iterator iter, iter2;
int main() {
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    MM[a[i]] = i;
  }
  SET.insert(a[1]);
  for (i = 2; i <= n; i++) {
    SET.insert(a[i]);
    iter = SET.lower_bound(a[i]);
    iter2 = SET.upper_bound(a[i]);
    if (iter == SET.begin()) {
      printf("%d ", *iter2);
      continue;
    }
    iter--;
    if (iter2 == SET.end()) {
      printf("%d ", *(iter));
      continue;
    }
    if (MM[*iter] > MM[*iter2])
      printf("%d ", *iter);
    else
      printf("%d ", *iter2);
  }
  return 0;
}
