#include <bits/stdc++.h>
using namespace std;
const long long inf = 100000000, mn = 200005;
long long n, i, a[mn], p[mn], k;
set<long long> s;
map<long long, pair<long long, long long> > m;
int main() {
  vector<long long> ans;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) {
      auto it = m.lower_bound(a[i]);
      if (it == m.end()) {
        it--;
        it->second.second = a[i];
        m[a[i]] = make_pair(-1, -1);
        ans.push_back(it->first);
      } else {
        if (it->second.first == -1) {
          it->second.first = a[i];
          m[a[i]] = make_pair(-1, -1);
          ans.push_back(it->first);
        } else {
          it--;
          it->second.second = a[i];
          m[a[i]] = make_pair(-1, -1);
          ans.push_back(it->first);
        }
      }
    } else {
      m[a[i]] = make_pair(-1, -1);
    }
  }
  for (i = 0; i < n - 1; i++) {
    cout << ans[i] << " ";
  }
}
