/*
ai<aj i</>j put in stack
ak<ai<aj i<j<k i,j 不能在一起 -> add i,j
二分图判断奇环 col[i] 的颜色
模拟 1 2 3 4
:::若a[i]<t1/2 就一直删除直到 降序排序
*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
//#include<queue>
//#include<vector>
#include<bits/stdc++.h>
#define ll long long
#define ddd printf("-----------------------\n");
using namespace std;
const int maxn=1e3+10 ;
const int inf=0x3f3f3f3f;
int n,a[maxn],col[maxn],f[maxn],t[maxn<<1],t1=inf,t2=inf;
int head[maxn],to[2*maxn*maxn],nxt[2*maxn*maxn],tot;
char cao[5]={'0','a','b','c','d'};
stack<int> st1,st2;
queue<int> q;
void add(int a,int b){
to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
}
int main()
{
ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
f[n+1]=inf;
for(int i=n;i>=1;i--) f[i]=min(f[i+1],a[i]);
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++)
if(a[i]<a[j]&&f[j+1]<a[i])
add(i,j),add(j,i);
}
for(int i=1;i<=n;i++)
{
if(col[i]==0)
{
col[i]=1; q.push(i);
while(!q.empty())
{
int u=q.front();q.pop();
for(int j=head[u];j;j=nxt[j])
{
int v=to[j];
if(col[v]){
if(col[v]^col[u]) continue;
cout<<"0\n"; return 0;
}
else col[v]=col[u]*(-1),q.push(v);//
}
}
}
}
int sum=1,cnt=0,i=1;
while(cnt<2*n)
{
if(st1.empty()==0) t1=st1.top();
if(st2.empty()==0) t2=st2.top();
if(col[i]==1&&(a[i]<t1||st1.empty())) t[++cnt]=1,st1.push(a[i]),i++;
else if(t1==sum) sum++,t[++cnt]=2,st1.pop();
else if(col[i]==-1&&(a[i]<t2||st2.empty())) t[++cnt]=3,st2.push(a[i]),i++;
else if(t2==sum) sum++,t[++cnt]=4,st2.pop();
}
for(int i=1;i<=2*n;i++)
cout<<cao[t[i]]<<" ";
cout<<'\n';
return 0;
}