#include <bits/stdc++.h>
using namespace std;
class DTreeConstruction {
 public:
  void solve(std::istream& in, std::ostream& out) {
    long long n;
    in >> n;
    set<pair<long long, long long>> s;
    long long x;
    in >> x;
    vector<long long> arr;
    s.insert({x - 1, x});
    s.insert({INT_MAX, x});
    map<long long, long long> parent;
    for (long long i = 0; i < n - 1; i++) {
      in >> x;
      arr.emplace_back(x);
      auto par = *s.upper_bound({x, -1});
      s.erase(par);
      parent[x] = par.second;
      s.insert({x - 1, x});
      s.insert({par.first, x});
    }
    for (long long x : arr) out << parent[x] << ' ';
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  DTreeConstruction solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
