#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
const int N = (int)1e5 + 11;
int a[N], n, res;
void solve() {
  cin >> n;
  set<int> st;
  map<int, int> left, right;
  for (int i = 0; i < n; i++) cin >> a[i];
  st.insert(a[0]);
  for (int i = 1; i < n; i++) {
    auto it = st.upper_bound(a[i]);
    if (it != st.end() and left.count(*it) == 0) {
      left[*it] = a[i];
      res = *it;
    } else {
      it--;
      right[*it] = a[i];
      res = *it;
    }
    st.insert(a[i]);
    cout << res << " \n"[i == n - 1];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  solve();
  return 0;
}
