#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> my;
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> p(n);
  for (int i = 0; i != n; i++) {
    cin >> v[i];
  }
  my[v[0]] = 0;
  p[0] = v[0];
  map<int, int>::iterator it;
  map<int, int>::iterator it1;
  map<int, int>::iterator it2;
  for (int i = 1; i != n; i++) {
    my[v[i]] = i;
    it = my.find(v[i]);
    it2 = it;
    it++;
    it1 = it;
    it = it2;
    if (it == my.begin()) {
      it++;
      p[i] = it->first;
    } else if (it1 == my.end()) {
      it--;
      p[i] = it->first;
    } else {
      it++;
      int g = it->second;
      it--;
      it--;
      int l = it->second;
      if (g > l) {
        it++;
        it++;
        p[i] = it->first;
      } else {
        p[i] = it->first;
      }
    }
    cout << p[i] << " ";
  }
  cout << endl;
}
