#include <bits/stdc++.h>
#define pi acos(-1.0 )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const int maxn =1e5 + 10;
const LL mod = 998244353;
int a[maxn];
map<int, int> mp;
int main()
{
int n; scanf("%d", &n);
for(int i=1; i<=n; i++) scanf("%d", &a[i]);
mp[0] = 0; mp[a[1]] = 1;
for(int i=2; i<=n; i++){
auto l = mp.lower_bound(a[i]);
auto r = l--;
auto now = l->second > r->second?l:r;
printf("%d ", now->first);
mp[a[i]] = mp[now->first]+1;
}puts("");
return 0;
}