#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long double EPS = 1e-9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long int n;
  cin >> n;
  set<pair<long int, long int> > arvore;
  long int x;
  cin >> x;
  arvore.insert(make_pair(x, 0));
  for (long long int i = 1; i < n; i++) {
    long int y;
    cin >> y;
    set<pair<long int, long int> >::iterator it =
        arvore.upper_bound(make_pair(y, 0));
    pair<long int, long int> ans;
    ans.second = -1;
    if (it != arvore.end()) {
      ans.first = it->first;
      ans.second = it->second;
    }
    if (it != arvore.begin()) {
      it--;
      if (it->second > ans.second) {
        ans.first = it->first;
        ans.second = it->second;
      }
    }
    arvore.insert(make_pair(y, i));
    cout << ans.first << ' ';
  }
  return 0;
}
