#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long inf = 1LL << 30;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const int N = 100100;
map<int, bool> L, R;
map<int, int> par;
set<int> s;
int a[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    s.insert(a[i - 1]);
    auto p = s.lower_bound(a[i]);
    if (p == s.end()) {
      p--;
      R[*p] = 1;
      par[a[i]] = *p;
      continue;
    }
    if (p == s.begin()) {
      L[*p] = 1;
      par[a[i]] = *p;
      continue;
    }
    if (L.count(*p)) {
      p--;
      R[*p] = 1;
      par[a[i]] = *p;
      continue;
    }
    L[*p] = 1;
    par[a[i]] = *p;
  }
  for (int i = 1; i < n; i++) printf("%d ", par[a[i]]);
}
