#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=100010;
const int MAX=1000000100;
const int mod=100000000;
const int MOD1=1000000007;
const int MOD2=1000000009;
const double EPS=0.00000001;
typedef long long ll;
const ll MOD=998244353;
const int INF=1000000010;
typedef double db;
typedef unsigned long long ull;
struct node {
int x,id;
bool operator < (const node a) const{
return x<a.x;
}
}b[N];
int n,a[N],ans[N];
node mi[4*N];
void build(int x,int l,int r) {
if (l==r) { mi[x]=b[l];return ; }
int mid=(l+r)>>1;
build(2*x,l,mid);
build(2*x+1,mid+1,r);
if (mid+1>r||mi[2*x].id<mi[2*x+1].id) mi[x]=mi[2*x];
else mi[x]=mi[2*x+1];
}
node get(int x,int l,int r,int L,int R) {
if (l==L&&r==R) return mi[x];
int mid=(L+R)>>1;
if (r<=mid) return get(2*x,l,r,L,mid);
else if (l>mid) return get(2*x+1,l,r,mid+1,R);
else {
node kk=get(2*x,l,mid,L,mid);
node gg=get(2*x+1,mid+1,r,mid+1,R);
if (kk.id<gg.id) return kk;
return gg;
}
}
void div(int l,int r,int x) {
if (l>r) return ;
node w=get(1,l,r,1,n);
ans[w.id]=x;
div(l,a[w.id]-1,w.x);div(a[w.id]+1,r,w.x);
}
int main()
{
int i;
scanf("%d", &n);
for (i=1;i<=n;i++) {
scanf("%d", &a[i]);
b[i].x=a[i];b[i].id=i;
}
sort(b+1,b+n+1);
for (i=1;i<=n;i++) a[b[i].id]=i;
build(1,1,n);
div(1,n,0);
for (i=2;i<=n;i++) printf("%d ", ans[i]);
printf("\n");
return 0;
}