#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1;
map<long long, pair<long long, long long>> rec;
long long find(long long x) {
  auto greater = rec.lower_bound(x);
  if (greater == rec.end()) {
    greater--;
    (greater->second).second = 1;
    rec[x] = {0, 0};
    return greater->first;
  }
  auto less = greater;
  long long ans = 0;
  if (less != rec.begin()) {
    less--;
  }
  if (x > less->first && (less->second).second == 0) {
    (less->second).second = 1;
    ans = less->first;
  }
  if (x < less->first) {
    (less->second).first = 1;
    ans = less->first;
  }
  if (x < greater->first && (greater->second).first == 0) {
    (greater->second).first = 1;
    ans = greater->first;
  }
  rec[x] = {0, 0};
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> ans(n);
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (i == 0) {
      rec[x] = {0, 0};
      continue;
    }
    ans[i] = find(x);
  }
  for (long long i = 1; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
