#include<bits/stdc++.h>
#define inf 1e18
#define endl "\n"
#define mp make_pair
#define pb push_back
#define loop(i,x,y) for(int i = x; i < y ; i++ )
#define all(x) (x).begin(),(x).end()
#define in(n)       int n; cin>>n;
#define inarr(arr,n) vector<int>arr(n); for(int i = 0; i < n ; i++){cin>>arr[i];}
#define maploop(x) for(auto itr = x.begin(); itr != x.end();itr++)
#define int long long
using namespace std;
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x<<" "; _print(x); cerr << endl;
#else
#define debug(x);
#endif

void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}


template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


const int N = 10001;
int mod = 1000000007;

void Main()
{
	string s;
	cin >> s;
	loop(i, 1, s.size())
	{
		cout << s[i];
	}
	cout << s[0] << endl;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)
	{
		Main();
	}
}

#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
	x=0;bool f=false;char ch=getchar();
	while(!isdigit(ch)){f|=ch=='-',ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return ;
}
template <typename T>
inline void write(T x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10^48);
	return ;
}
const int N=2e5+25,MOD=998244353;
#define ll long long
int n,a[N],t[N],sta[N],top;
bool vis[N];
signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),t[a[i]]=i;
	for(int i=1;i<=n;i++){
		while(t[i]>i){
			if(vis[t[i]-1]){write(-1);return 0;}
			int tmp=t[i];
			t[i]=tmp-1,t[a[tmp-1]]=tmp;
			swap(a[tmp],a[tmp-1]);vis[t[i]]=true;
			sta[++top]=t[i];
		}
		while(t[i]<i){
			if(vis[t[i]]){write(-1);return 0;}
			int tmp=t[i];
			t[i]=tmp+1,t[a[tmp+1]]=tmp;
			swap(a[tmp],a[tmp+1]);vis[tmp]=true;
			sta[++top]=tmp;
		}
	}
	if(top!=n-1) write(-1);
	else{for(int i=1;i<=top;i++) write(sta[i]),putchar('\n');}
	return 0;
}