#include <bits/stdc++.h>
using namespace std;
long long a[200000];
const int Max = 200000;
set<int> q;
map<int, int> p;
int i, j;
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  q.insert(0);
  q.insert(a[1]);
  p[a[1]] = 1;
  for (int i = 2; i <= n; i++) {
    auto it = q.lower_bound(a[i]);
    auto pos = it;
    it--;
    if (p[*it] < p[*pos]) {
      cout << *pos << " ";
    } else {
      cout << *it << " ";
    }
    p[a[i]] = i;
    q.insert(a[i]);
  }
  return 0;
}
