#include <bits/stdc++.h>
inline int Rand() { return (rand() << 16) | rand(); }
using namespace std;
const int N = 200005;
const double eps = 1e-9;
set<pair<long long, int> > s;
int main() {
  int n;
  long long a, b;
  cin >> n;
  cin >> b;
  s.insert(make_pair(b, 1));
  for (int i = 2; i <= n; ++i) {
    cin >> a;
    set<pair<long long, int> >::iterator it = s.lower_bound(make_pair(a, 0));
    if (it == s.end())
      it--, cout << it->first << " ", s.insert(make_pair(a, it->second + 1));
    else if (it == s.begin())
      cout << it->first << " ", s.insert(make_pair(a, it->second + 1));
    else {
      it--;
      set<pair<long long, int> >::iterator il = it;
      it++;
      if (it->second > il->second)
        cout << it->first << " ", s.insert(make_pair(a, it->second + 1));
      else
        cout << il->first << " ", s.insert(make_pair(a, il->second + 1));
    }
  }
  return 0;
}
