#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long powx(long long a, long long p) {
  long long ans = 1;
  for (int i = 0; i < p; i++) ans *= a;
  return ans;
}
struct Node {
  int data;
  Node* left;
  Node* right;
  Node(int val) {
    data = val;
    left = NULL;
    right = NULL;
  }
};
int arr[100005], par[100005];
void inorder(Node* node) {
  if (node == NULL) return;
  inorder(node->left);
  cout << node->data << " ";
  inorder(node->right);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  unordered_map<int, int> m;
  m[arr[0]] = 0;
  set<int> s;
  s.insert(arr[0]);
  for (int i = 1; i < n; i++) {
    auto l = s.lower_bound(arr[i]);
    auto u = s.upper_bound(arr[i]);
    if (u == s.end()) {
      l--;
      cout << *l << " ";
    } else if (l == s.begin()) {
      cout << *u << " ";
    } else {
      l--;
      if (m[*l] < m[*u]) {
        cout << *u << " ";
      } else
        cout << *l << " ";
    }
    s.insert(arr[i]);
    m[arr[i]] = i;
  }
  return 0;
}
