#include <bits/stdc++.h>
using namespace std;
set<long long> s;
set<long long>::iterator it1, it2;
map<long long, long long> pos;
long long a[200000];
int main() {
  long long n, i;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i], pos[a[i]] = i;
  s.insert(a[0]);
  for (i = 1; i < n; i++) {
    if (s.size() == 1)
      cout << *(s.begin()) << " ";
    else if (*(s.begin()) > a[i])
      cout << *(s.begin()) << " ";
    else {
      it2 = s.lower_bound(a[i]);
      it1 = it2;
      it2--;
      if (pos[*it1] > pos[*it2])
        cout << *it1 << " ";
      else
        cout << *it2 << " ";
    }
    s.insert(a[i]);
  }
  return 0;
}
