#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const unsigned long long mx = 133333331;
inline void RI(int &x) {
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
set<int> s;
map<int, int> l, r;
int main() {
  int n;
  while (cin >> n) {
    l.clear(), r.clear();
    s.clear();
    for (int i = 0; i < n; i++) {
      int a;
      scanf("%d", &a);
      if (i) {
        set<int>::iterator L = s.lower_bound(a);
        set<int>::iterator R = s.lower_bound(a);
        if (L == s.begin()) {
          printf("%d", *R);
          l[*R] = a;
        } else if (R == s.end()) {
          L--;
          printf("%d", *L);
          r[*L] = a;
        } else {
          L--;
          if (r[*L]) {
            printf("%d", *R);
            l[*R] = a;
          } else {
            printf("%d", *L);
            r[*L] = a;
          }
        }
      }
      s.insert(a);
      if (i) {
        if (i == n - 1)
          printf("\n");
        else
          printf(" ");
      }
    }
  }
  return 0;
}
