#include <bits/stdc++.h>
using namespace std;
map<int, bool> childL, childR;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  int n, a;
  cin >> n;
  cin >> a;
  multiset<int> mulset;
  mulset.insert(a);
  for (int i = 1; i < n; i++) {
    cin >> a;
    auto ite = mulset.lower_bound(a);
    if (childL[*ite] || ite == mulset.end()) {
      ite--;
      childR[*ite] = 1;
    } else
      childL[*ite] = 1;
    if (i > 1) cout << " ";
    cout << *ite;
    mulset.insert(a);
  }
  cout << endl;
}
