#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> nums;
  map<int, int, greater<int>> gnums;
  int in;
  cin >> in;
  nums[in] = 1;
  gnums[in] = 1;
  for (int i = 1; i < n; ++i) {
    int in;
    cin >> in;
    auto prev = gnums.upper_bound(in);
    auto next = nums.upper_bound(in);
    if (prev == gnums.end()) {
      cout << next->first << " ";
    } else if (next == nums.end()) {
      cout << prev->first << " ";
    } else if (next->second > prev->second) {
      cout << next->first << " ";
    } else {
      cout << prev->first << " ";
    }
    nums[in] = i + 1;
    gnums[in] = i + 1;
  }
}
