#include <bits/stdc++.h>
using namespace std;
int a[100010];
map<int, int> M;
set<int> s;
map<int, int> par;
map<int, int> dir;
int ans[100010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  s.insert(-1000000007);
  s.insert(a[1]);
  s.insert(1000000007);
  par[-1000000007] = 1;
  par[a[1]] = 1;
  dir[-1000000007] = 1;
  par[1000000007] = 1;
  dir[1000000007] = 2;
  ans[1] = 1;
  int p;
  for (int i = 2; i <= n; i++) {
    set<int>::iterator it = s.lower_bound(a[i]);
    it--;
    p = *it;
    ans[i] = par[p];
    s.insert(a[i]);
    par[p] = i;
    par[a[i]] = i;
  }
  for (int i = 2; i <= n; i++) cout << a[ans[i]] << " ";
  cout << endl;
  return 0;
}
