#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > st;
int arr[100100];
int main() {
  int n, i, j, k, l, m;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  st.insert(pair<int, int>(arr[0], 0));
  for (i = 1; i < n; i++) {
    auto it = st.upper_bound(pair<int, int>(arr[i], 0));
    if (it != st.begin()) {
      auto ti = it;
      ti--;
      if (it == st.end() || (*ti).second > (*it).second) it = ti;
    }
    cout << (*it).first << " ";
    st.insert(pair<int, int>(arr[i], i));
  }
  cout << endl;
}
