#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e5 + 10;
const long long mod = 998244353;
int a[maxn];
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  mp[0] = 0;
  mp[a[1]] = 1;
  for (int i = 2; i <= n; i++) {
    auto l = mp.lower_bound(a[i]);
    auto r = l--;
    auto now = l->second > r->second ? l : r;
    printf("%d ", now->first);
    mp[a[i]] = mp[now->first] + 1;
  }
  puts("");
  return 0;
}
