#include <bits/stdc++.h>
using namespace std;
long long rd(long long &x) { return scanf("%lld", &x); }
long long rd(long long &x, long long &y) { return scanf("%lld %lld", &x, &y); }
long long rd(long long &x, long long &y, long long &z) {
  return scanf("%lld %lld %lld", &x, &y, &z);
}
long long rd(long long &x, long long &y, long long &z, long long &s) {
  return scanf("%lld %lld %lld %lld", &x, &y, &z, &s);
}
void shaon() { cerr << endl; }
template <typename T, typename... north>
void shaon(T arg, const north &...rest) {
  cerr << arg << ' ';
  shaon(rest...);
}
const long long N = 1e5 + 5;
long long n, x;
set<pair<long long, long long> > s;
int main() {
  rd(n, x);
  s.insert(make_pair(x, 0));
  for (long long i = 1; i <= (n - 1); i++) {
    rd(x);
    pair<long long, long long> p = make_pair(x, i);
    auto it = s.lower_bound(p);
    if (it == s.end())
      it--;
    else if (it != s.begin()) {
      auto it2 = it;
      it2--;
      if (it2->second > it->second) it = it2;
    }
    printf("%lld ", it->first);
    s.insert(p);
  }
  return 0;
}
