#include <bits/stdc++.h>
using namespace std;
int n, a, ans;
int main() {
  while (cin >> n) {
    set<int> s;
    set<int>::iterator low, high;
    map<int, int> m;
    cin >> a;
    m[a] = 0;
    s.insert(a);
    for (int i = 1; i < n; i++) {
      cin >> a;
      s.insert(a);
      m[a] = i;
      low = s.lower_bound(a);
      low--;
      high = s.upper_bound(a);
      if (low == s.end())
        ans = *high;
      else if (high == s.end())
        ans = *low;
      else {
        ans = (m[*low] > m[*high] ? *low : *high);
      }
      cout << ans << " ";
    }
    cout << endl;
  }
  return 0;
}
