using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5");
WillReturn.Add("2 4 1 5 3");
//4
//2
//3
//1
}
else if (InputPattern == "Input2") {
WillReturn.Add("5");
WillReturn.Add("5 4 3 2 1");
//-1
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
int[] AArr = InputList[1].Split(' ').Select(pX => int.Parse(pX)).ToArray();
int UB = AArr.GetUpperBound(0);
// Ind[値]なDict
var IndDict = new Dictionary<int, int>();
for (int I = 0; I <= UB; I++) {
IndDict[AArr[I]] = I;
}
var EdgeSet = new HashSet<string>();
var EdgeList = new List<string>();
for (int I = 1; I <= N; I++) {
int CurrInd = IndDict[I];
while (CurrInd > I - 1) {
int Ind1 = CurrInd;
int Ind2 = CurrInd - 1;
string Hash = GetHash(Ind1, Ind2);
if (EdgeSet.Add(Hash) == false) {
Console.WriteLine(-1);
return;
}
EdgeList.Add(Hash);
int tmp = AArr[Ind1];
AArr[Ind1] = AArr[Ind2];
AArr[Ind2] = tmp;
IndDict[AArr[Ind1]] = Ind1;
IndDict[AArr[Ind2]] = Ind2;
CurrInd--;
}
}
// 全ての枝を使用済であること
if (EdgeSet.Count != N - 1) {
Console.WriteLine(-1);
return;
}
// 昇順にソートされてること
for (int I = 0; I <= UB; I++) {
if (AArr[I] != I + 1) {
Console.WriteLine(-1);
return;
}
}
foreach (string EachHash in EdgeList) {
Console.WriteLine(Regex.Match(EachHash, "[0-9]+$").Value);
}
}
// 枝のハッシュ値を返す
static string GetHash(int pInd1, int pInd2)
{
int MinInd = Math.Min(pInd1, pInd2);
int MaxInd = Math.Max(pInd1, pInd2);
return string.Format("{0},{1}", MinInd, MaxInd);
}
}