#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1e5 + 10;
map<int, bool> okl, okr;
multiset<int> s;
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) {
    int x = read(), v;
    if (i > 1) {
      set<int>::iterator it;
      it = s.lower_bound(x);
      if (it != s.end() && okl[*it] == 0) {
        okl[*it] = 1;
        v = *it;
      } else {
        it = s.upper_bound(x);
        it--;
        if (it != s.end() && okr[*it] == 0) {
          okr[*it] = 1;
          v = *it;
        }
      }
      cout << v << " ";
    }
    s.insert(x);
    okl[x] = okr[x] = 0;
  }
  puts("");
  return 0;
}
