#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
#define ll long long
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(ll i=a;i<=b;++i)
#define fast ios::sync_with_stdio(0);cin.tie(0);
ll n;
void input(){
cin>>n;
vll f(n+1);
fo(i,1,n)cin>>f[i];
if(f[1]!=0){
cout<<-1;
return;
}
string S(n+1,' ');
S[1]='a';
vll pi(n+1,0);
pi[1]=0;
bool valid=true;
fo(i,2,n){
if(f[i]>0){
char c=S[f[i]];
ll j=pi[i-1];
while(j>0&&S[j+1]!=c) j=pi[j];
if(S[j+1]==c) j++;
if(j!=f[i]){
valid=false;
break;
}
S[i]=c;
pi[i]=j;
} else {
bool found=false;
for(char c='a';c<='z';c++){
ll j=pi[i-1];
while(j>0&&S[j+1]!=c) j=pi[j];
if(S[j+1]==c) j++;
if(j==0){
S[i]=c;
pi[i]=0;
found=true;
break;
}
}
if(!found){
valid=false;
break;
}
}
}
cout<<(valid ? S.substr(1) : "-1");
}
int main(){
freopen("PREFIX.inp","r",stdin);
freopen("PREFIX.out","w",stdout);
fast
input();
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8zLHVucm9sbC1sb29wcyIpICAKI3ByYWdtYSBHQ0MgdGFyZ2V0KCJhdngyLGJtaSxibWkyLHBvcGNudCxsemNudCIpICAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdmxsIHZlY3RvcjxsbD4KI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLHguZW5kKCkKI2RlZmluZSBmbyhpLGEsYikgZm9yKGxsIGk9YTtpPD1iOysraSkKI2RlZmluZSBmYXN0IGlvczo6c3luY193aXRoX3N0ZGlvKDApO2Npbi50aWUoMCk7CgpsbCBuOwoKdm9pZCBpbnB1dCgpewogICAgY2luPj5uOwogICAgdmxsIGYobisxKTsKICAgIGZvKGksMSxuKWNpbj4+ZltpXTsKCiAgICBpZihmWzFdIT0wKXsKICAgICAgICBjb3V0PDwtMTsKICAgICAgICByZXR1cm47CiAgICB9CgogICAgc3RyaW5nIFMobisxLCcgJyk7CiAgICBTWzFdPSdhJzsKICAgIHZsbCBwaShuKzEsMCk7CiAgICBwaVsxXT0wOwogICAgYm9vbCB2YWxpZD10cnVlOwoKICAgIGZvKGksMixuKXsKICAgICAgICBpZihmW2ldPjApewogICAgICAgICAgICBjaGFyIGM9U1tmW2ldXTsKICAgICAgICAgICAgbGwgaj1waVtpLTFdOwogICAgICAgICAgICB3aGlsZShqPjAmJlNbaisxXSE9Yykgaj1waVtqXTsKICAgICAgICAgICAgaWYoU1tqKzFdPT1jKSBqKys7CiAgICAgICAgICAgIGlmKGohPWZbaV0pewogICAgICAgICAgICAgICAgdmFsaWQ9ZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBTW2ldPWM7CiAgICAgICAgICAgIHBpW2ldPWo7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYm9vbCBmb3VuZD1mYWxzZTsKICAgICAgICAgICAgZm9yKGNoYXIgYz0nYSc7Yzw9J3onO2MrKyl7CiAgICAgICAgICAgICAgICBsbCBqPXBpW2ktMV07CiAgICAgICAgICAgICAgICB3aGlsZShqPjAmJlNbaisxXSE9Yykgaj1waVtqXTsKICAgICAgICAgICAgICAgIGlmKFNbaisxXT09YykgaisrOwogICAgICAgICAgICAgICAgaWYoaj09MCl7CiAgICAgICAgICAgICAgICAgICAgU1tpXT1jOwogICAgICAgICAgICAgICAgICAgIHBpW2ldPTA7CiAgICAgICAgICAgICAgICAgICAgZm91bmQ9dHJ1ZTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZighZm91bmQpewogICAgICAgICAgICAgICAgdmFsaWQ9ZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBjb3V0PDwodmFsaWQgPyBTLnN1YnN0cigxKSA6ICItMSIpOwp9CgppbnQgbWFpbigpewogICAgZnJlb3BlbigiUFJFRklYLmlucCIsInIiLHN0ZGluKTsKICAgIGZyZW9wZW4oIlBSRUZJWC5vdXQiLCJ3IixzdGRvdXQpOwogICAgZmFzdAogICAgaW5wdXQoKTsKfQo=