#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
set<int> s;
int main() {
  int n;
  scanf("%d", &n);
  int p;
  scanf("%d", &p);
  s.insert(p);
  m[p] = 0;
  set<int>::iterator it, itt;
  for (int i = 1; i < n; i++) {
    if (i != 1) printf(" ");
    scanf("%d", &p);
    it = s.lower_bound(p);
    if (it == s.begin())
      printf("%d", *it);
    else {
      itt = it;
      itt--;
      if (m[*it] > m[*itt])
        printf("%d", *it);
      else
        printf("%d", *itt);
    }
    s.insert(p);
    m[p] = i;
  }
  printf("\n");
}
