Little Robber Girl likes to scare animals in her zoo for fun. She decided to arrange the animals in a row in the order of non-decreasing height. However, the animals were so scared that they couldn't stay in the right places.

The robber girl was angry at first, but then she decided to arrange the animals herself. She repeatedly names numbers l and r such that r - l + 1 is even. After that animals that occupy positions between l and r inclusively are rearranged as follows: the animal at position l swaps places with the animal at position l + 1, the animal l + 2 swaps with the animal l + 3, ..., finally, the animal at position r - 1 swaps with the animal r.

Help the robber girl to arrange the animals in the order of non-decreasing height. You should name at most 20 000 segments, since otherwise the robber girl will become bored and will start scaring the animals again.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 100) — number of animals in the robber girl's zoo.

The second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is the height of the animal occupying the i-th place.


-----Output-----

Print the sequence of operations that will rearrange the animals by non-decreasing height.

The output should contain several lines, i-th of the lines should contain two space-separated integers l_{i} and r_{i} (1 ≤ l_{i} < r_{i} ≤ n) — descriptions of segments the robber girl should name. The segments should be described in the order the operations are performed.

The number of operations should not exceed 20 000.

If the animals are arranged correctly from the start, you are allowed to output nothing.


-----Examples-----
Input
4
2 1 4 3

Output
1 4

Input
7
36 28 57 39 66 69 68

Output
1 4
6 7

Input
5
1 2 1 2 1

Output
2 5
3 4
1 4
1 4



-----Note-----

Note that you don't have to minimize the number of operations. Any solution that performs at most 20 000 operations is allowed.

Difficulty: EASY
Tags: Sorting

Implementation

Constructive algorithms
Skill types: Sorting

Starter code:

Solutions:
n = int(input())
arr = list(map(int, input().split()))
for i in range(n - 1, 0, -1):
	for j in range(i):
		if arr[j] > arr[j + 1]:
			(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
			print(j + 1, j + 2)


n = int(input())
a = input()
a = a.split()
b = []
for i in range(n):
	a[i] = int(a[i])
for j in range(n - 1):
	for i in range(n - j - 1):
		if a[i] > a[i + 1]:
			t = a[i]
			a[i] = a[i + 1]
			a[i + 1] = t
			print(i + 1, i + 2)


n = int(input())
animals = list(map(int, input().split()))
copy = list(animals)
copy.sort()
moves = []
while True:
	for i in range(n - 1):
		if animals[i] > animals[i + 1]:
			temp = animals[i]
			animals[i] = animals[i + 1]
			animals[i + 1] = temp
			moves.append(str(i + 1) + ' ' + str(i + 2))
	if animals == copy:
		break
for i in moves:
	print(i)


import sys
n = int(input())
a = list(map(int, input().split()))
p = 1
while p:
	p = 0
	for i in range(0, n - 1):
		if a[i] > a[i + 1]:
			print(i + 1, i + 2)
			t = a[i]
			a[i] = a[i + 1]
			a[i + 1] = t
			p = 1


n = int(input())
arr = [int(x) for x in input().split()]
while True:
	suc = 0
	for i in range(1, n):
		if arr[i - 1] > arr[i]:
			(arr[i - 1], arr[i]) = (arr[i], arr[i - 1])
			print(i, i + 1)
			suc = 1
	if suc == 0:
		break


from sys import stdin as Si, maxsize as m
from math import floor as F
from collections import defaultdict as dt, Counter as Co
from operator import itemgetter as ig
from math import pi
from itertools import product as P
n = int(Si.readline())
A = list(map(int, Si.readline().split()))
for i in range(n):
	Aa = sorted(((A[x], x) for x in range(n)))
	(t, j) = Aa[i]
	if j > i:
		for x in range(j, i, -1):
			print(x, x + 1)
			(A[x], A[x - 1]) = (A[x - 1], A[x])


n = int(input())
a = list(map(int, input().split()))

def swap(i, j):
	global a
	r = a[i]
	a[i] = a[j]
	a[j] = r
for i in range(n - 1):
	for j in range(0, n - 1 - i):
		if a[j] > a[j + 1]:
			swap(j, j + 1)
			print(j + 1, j + 2)


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	for j in range(n - 1, i, -1):
		if a[j] < a[j - 1]:
			(a[j], a[j - 1]) = (a[j - 1], a[j])
			print(j, j + 1)


n = int(input())
A = list(map(int, input().split()))
for i in range(n):
	for j in range(n - i - 1):
		if A[j] > A[j + 1]:
			(A[j], A[j + 1]) = (A[j + 1], A[j])
			print(j + 1, j + 2)


def all_good(a):
	for i in range(1, len(a)):
		if a[i] < a[i - 1]:
			return False
	return True

def swaperoo(a, l, r):
	for i in range(l, r + 1, 2):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
n = int(input())
a = list(map(int, input().split()))
while not all_good(a):
	l = -1
	r = -1
	for i in range(1, len(a)):
		if a[i] < a[i - 1]:
			l = i - 1
			break
	for i in range(len(a) - 2, 0, -1):
		if a[i] > a[i + 1]:
			r = i
			break
	if (r - l + 1) % 2 != 0:
		if r != n - 1:
			r = r + 1
		elif l != 0:
			l = l - 1
		elif l != n - 1:
			l = l - 1
		elif r != 0:
			r = r + 1
	swaperoo(a, l, r)
	print(l + 1, r + 1)


import os
n = int(input())
a = list(map(int, input().split(' ')))
steps = []
for i in range(n, -1, -1):
	for j in range(i - 1):
		if a[j] <= a[j + 1]:
			continue
		(a[j], a[j + 1]) = (a[j + 1], a[j])
		steps.append('{} {}'.format(j + 1, j + 2))
print(os.linesep.join(steps))


import copy
n = int(input())
arr = [int(x) for x in input().split(' ')]
carr = copy.deepcopy(arr)
carr.sort()
while True:
	for i in range(n - 1):
		if arr[i] <= arr[i + 1]:
			continue
		j = i
		while arr[j] > arr[j + 1]:
			(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
			print(j + 1, j + 2)
			j += 1
			if j == n - 1:
				break
	if carr == arr:
		exit()


def isSorted(a):
	for i in range(0, len(a) - 1):
		if a[i] > a[i + 1]:
			return False
	return True
n = int(input())
a = [int(x) for x in input().split()]
while not isSorted(a):
	for i in range(0, n - 1):
		if a[i] > a[i + 1]:
			print(i + 1, i + 2)
			(a[i + 1], a[i]) = (a[i], a[i + 1])


n = int(input())
t = [int(i) for i in input().split()]
while sorted(t) != t:
	i = 0
	while t[i] <= t[i + 1]:
		i += 1
	nb = 1
	bestnb = 1
	bestj = 0
	j = 1
	while i + 2 * j + 1 < len(t):
		if t[i + 2 * j] <= t[i + 2 * j + 1]:
			nb -= 1
		else:
			nb += 1
		if nb > bestnb:
			(bestnb, bestj) = (nb, j)
		j += 1
	print(i + 1, i + 2 * bestj + 2)
	for j in range(0, bestj + 1):
		(t[i + 2 * j], t[i + 2 * j + 1]) = (t[i + 2 * j + 1], t[i + 2 * j])


num = int(input())
heights = list(map(int, input().split()))

def find_index_smallest(list):
	i = 0
	for x in range(0, len(list)):
		if list[x] < list[i]:
			i = x
	return i

def swap(list, i):
	tmp = list[i + 1]
	list[i + 1] = list[i]
	list[i] = tmp

def main(num, heights):
	output = []
	for x in range(0, num):
		s = find_index_smallest(heights[x:])
		s = s + x
		while s > x:
			swap(heights, s - 1)
			output.append((s - 1, s))
			s = s - 1
	return output

def pretty_print(seq):
	for (a, b) in seq:
		print(a + 1, ' ', b + 1)
seq = main(num, heights)
pretty_print(seq)


input()
heights = list(map(int, input().split()))
sortedHeights = sorted(heights)
for (i, item) in enumerate(sortedHeights):
	index = heights[i:].index(item) + i
	if index > i:
		for current in range(index - i):
			c = index - current - 1
			(heights[c + 1], heights[c]) = (heights[c], heights[c + 1])
			print(c + 1, c + 2)


n = int(input())
a = [int(x) for x in input().split()]
for outer in range(n - 1):
	for inner in range(n - 1):
		if a[inner] > a[inner + 1]:
			temp = a[inner]
			a[inner] = a[inner + 1]
			a[inner + 1] = temp
			print(str(inner + 1) + ' ' + str(inner + 2))


import sys
n = int(input())
arr = list(map(int, input().split()))
shiftnumber = 1
while shiftnumber != 0:
	shiftnumber = 0
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			print(i + 1, i + 2)
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			shiftnumber = 1


def main():
	n = int(input())
	l = [0] + list(map(int, input().split()))
	for (i, j) in enumerate(sorted(range(n + 1), key=l.__getitem__)):
		l[j] = i
	for i in range(n, 0, -1):
		if l[i] != i:
			for j in range(l.index(i), i):
				(l[j], l[j + 1]) = (l[j + 1], l[j])
				print(j, j + 1)
main()


def solve(n, seq):
	outer = 0
	while outer < n:
		inner = 0
		while inner < n - outer - 1:
			if seq[inner] > seq[inner + 1]:
				(seq[inner], seq[inner + 1]) = (seq[inner + 1], seq[inner])
				print(inner + 1, inner + 2)
			inner += 1
		outer += 1
n = int(input())
seq = list(map(int, input().split()))
solve(n, seq)


n = int(input())
a = list(map(int, input().split()))
ans = []
coun = 0

def maxin(a):
	global coun
	x = a.index(max(a))
	while x < len(a) - 1:
		ans.append((x + 1, x + 2))
		coun += 1
		(a[x], a[x + 1]) = (a[x + 1], a[x])
		x = x + 1
	a = a[:-1]
	return a
while len(a) != 1:
	a = maxin(a)
for i in ans:
	print(i[0], i[1])


n = int(input())
a = [int(s) for s in input().split()]
for j in range(n):
	k = 0
	i = 0
	while i < n - 1:
		if a[i] > a[i + 1]:
			k += 1
			tmp = a[i]
			a[i] = a[i + 1]
			a[i + 1] = tmp
			print(i + 1, i + 2)
		i += 2
	i = 1
	while i < n - 1:
		if a[i] > a[i + 1]:
			k += 1
			tmp = a[i]
			a[i] = a[i + 1]
			a[i + 1] = tmp
			print(i + 1, i + 2)
		i += 2
	if k == 0:
		break


n = int(input())
l = list(map(int, input().split()))
is_sorted = False
res = []
while is_sorted == False:
	is_sorted = True
	i = 0
	while i < n - 1:
		if l[i] > l[i + 1]:
			aux = l[i]
			l[i] = l[i + 1]
			l[i + 1] = aux
			res.append((i, i + 1))
			is_sorted = False
			print(i + 1, i + 2)
			i += 2
		else:
			i += 1


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	x = i
	while x > 0:
		if a[x] > a[x - 1]:
			break
		print(str(x) + ' ' + str(x + 1))
		tmp = a[x]
		a[x] = a[x - 1]
		a[x - 1] = tmp
		x -= 1


import math
import random

def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	for i in range(n):
		for j in range(1, n):
			if a[j - 1] > a[j]:
				print(j, j + 1)
				(a[j - 1], a[j]) = (a[j], a[j - 1])
main()


n = int(input())
arr = [int(i) for i in input().split()]
for i in range(n):
	for j in range(n - i - 1):
		if arr[j] > arr[j + 1]:
			(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
			print(j + 1, j + 2)


n = int(input())
a = [int(i) for i in input().split()]

def isSorted():
	for i in range(1, n):
		if a[i] < a[i - 1]:
			return False
	return True
while not isSorted():
	b = []
	k = 0
	i = 1
	while i < n:
		if a[i] < a[i - 1]:
			if k != 0 and i - 1 - b[k - 1][1] == 1:
				b[k - 1][1] = i
			else:
				b.append([i - 1, i])
				k += 1
			(a[i], a[i - 1]) = (a[i - 1], a[i])
			i += 2
		else:
			i += 1
	for i in b:
		print(i[0] + 1, i[1] + 1)


read = lambda : list(map(int, input().split()))
n = int(input())
a = list(read())
for i in range(n):
	for j in range(n - 1):
		if a[j] > a[j + 1]:
			print(j + 1, j + 2)
			(a[j], a[j + 1]) = (a[j + 1], a[j])


import sys
ii = lambda : int(sys.stdin.readline())
mi = lambda : map(int, sys.stdin.readline().split())
li = lambda : list(mi())
si = lambda : sys.stdin.readline()
n = ii()
l = li()
s = []
for i in range(n):
	for j in range(n - i - 1):
		if l[j] > l[j + 1]:
			s.append((j + 1, j + 2))
			(l[j], l[j + 1]) = (l[j + 1], l[j])
for (i, j) in s:
	print(f'{i} {j}')


n = int(input())
arr = [int(x) for x in input().split()]

def main():
	i = funct(arr)
	while True:
		if i == 1:
			break
		else:
			i = funct(arr)

def checksorted(arr):
	i = 0
	while i < len(arr) - 1:
		if arr[i] <= arr[i + 1]:
			i += 1
			continue
		else:
			return 0
	return 1

def operation(arr, start, end):
	while start < end:
		temp = arr[start]
		arr[start] = arr[start + 1]
		arr[start + 1] = temp
		start += 2

def funct(arr):
	start = 0
	end = 0
	i = 0
	if checksorted(arr) == 1:
		return 1
	else:
		while i < len(arr) - 1:
			if arr[i] > arr[i + 1]:
				i += 2
				end = i - 1
				continue
			else:
				if end != 0:
					break
				i += 1
				if end == 0:
					start += 1
		print(start + 1, end + 1)
		operation(arr, start, end)
main()


n = int(input())
a = list(map(int, input().split()))
swaps = []
for i in range(n):
	smallest = a[i]
	best_pos = i
	for j in range(i + 1, n):
		if a[j] < smallest:
			smallest = a[j]
			best_pos = j
	while best_pos > i:
		(a[best_pos - 1], a[best_pos]) = (a[best_pos], a[best_pos - 1])
		swaps.append((best_pos, best_pos + 1))
		best_pos -= 1
for (a, b) in swaps:
	print(a, b)


n = int(input())
l = [int(i) for i in input().split()]
for i in range(n):
	for j in range(0, n - 1):
		if l[j] > l[j + 1]:
			print(j + 1, j + 2)
			(l[j + 1], l[j]) = (l[j], l[j + 1])


import sys
n = [int(x) for x in sys.stdin.readline().split()][0]
a = [int(x) for x in sys.stdin.readline().split()]
c = 0
b = sorted(a)
while a != b:
	s = -1
	e = 0
	l = -1
	ms = -1
	me = -1
	ml = -1
	next = False
	for i in range(0, n):
		if next:
			next = False
			continue
		if i + 1 == n:
			break
		if a[i] > a[i + 1]:
			if s == -1:
				s = i
				l = 0
			e = i + 1
			l += 1
			next = True
		else:
			if l > ml:
				ml = l
				ms = s
				me = e
			l = -1
			s = -1
	if l > ml:
		ml = l
		ms = s
		me = e
	for i in range(ms, me, 2):
		tmp = a[i + 1]
		a[i + 1] = a[i]
		a[i] = tmp
	print(ms + 1, me + 1)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(len(a)):
		for j in range(len(a) - 1):
			if a[j] > a[j + 1]:
				print(j + 1, j + 2)
				(a[j], a[j + 1]) = (a[j + 1], a[j])
main()


def f(arr, n):
	for i in range(n, 1, -1):
		for j in range(1, i):
			if arr[j] < arr[j - 1]:
				print(j, j + 1)
				(arr[j], arr[j - 1]) = (arr[j - 1], arr[j])
n = int(input())
a = [int(z) for z in input().split()]
f(a, n)


a = int(input())
b = input()
b = b.split(' ')
b = map(int, b)
b = list(b)
g = b.copy()
g.sort()
while b != g:
	f = 0
	r = 0
	t = -1
	for i in range(len(b) - 1):
		if b[i] > b[i + 1]:
			r = i
			f = i
			break
	for i in range(f, len(b) - 1, 2):
		f = f + 1
		if b[i] > b[i + 1]:
			f = f + 1
		else:
			f = f - 1
			t = f
			break
	if t == -1:
		t = f
	t = t - 1
	print(r + 1, t + 1)
	for i in range(r, t, 2):
		p = b[i]
		b[i] = b[i + 1]
		b[i + 1] = p


from sys import stdin, stdout
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
flag = True
while flag:
	flag = False
	x = 0
	while x < n - 1:
		if s[x] > s[x + 1]:
			flag = True
			y = s[x + 1]
			s[x + 1] = s[x]
			s[x] = y
			stdout.write('%d %d \n' % (x + 1, x + 2))
			x += 2
		else:
			x += 1


x = int(input())
a = [0] * x
a = list(map(int, input().split()))
(cont1, cont2) = (0, 0)
(ini, fin) = (0, 0)

def reordenar(lista, m, n):
	for _ in range(m, n + 1, 2):
		(lista[_ - 1], lista[_]) = (lista[_], lista[_ - 1])
while cont1 < len(a):
	aux = []
	cont2 = cont1
	while cont2 < x - 1 and a[cont2] > a[cont2 + 1]:
		aux.append(cont2)
		cont2 = cont2 + 2
	if cont2 != cont1:
		print(aux[0] + 1, aux[-1] + 2)
		reordenar(a, aux[0] + 1, aux[-1] + 1)
		cont1 = 1 * -1
	cont1 += 1


n = int(input())
zoo = list(map(int, input().split()))
for _ in range(n):
	for i in range(n - 1):
		if zoo[i] > zoo[i + 1]:
			print(i + 1, i + 2)
			(zoo[i], zoo[i + 1]) = (zoo[i + 1], zoo[i])


import sys
n = int(input())
z = list(map(int, input().split()))
now = [0, 0]
for i in range(n):
	for j in range(n - i - 1):
		if z[j] > z[j + 1]:
			print(j + 1, j + 2)
			(z[j], z[j + 1]) = (z[j + 1], z[j])


import sys

def main():
	n = int(sys.stdin.readline())
	x = list(map(int, sys.stdin.readline().split()))
	found = True
	while found:
		found = False
		for i in range(1, n):
			if x[i] < x[i - 1]:
				found = True
				print(i, i + 1)
				(x[i - 1], x[i]) = (x[i], x[i - 1])
main()


n = int(input())
a = [int(x) for x in input().split()]
for i in range(0, n):
	minj = i
	for j in range(i, n):
		if a[minj] > a[j]:
			minj = j
	while minj > i:
		print(minj, minj + 1)
		t = a[minj]
		a[minj] = a[minj - 1]
		a[minj - 1] = t
		minj -= 1


_ = input()
animals = list(map(int, input().split(' ')))
l = -1
sorted = False
while not sorted:
	sorted = True
	i = 0
	while i < len(animals) - 1:
		if animals[i + 1] < animals[i]:
			sorted = False
			if l == -1:
				l = i + 1
			(animals[i + 1], animals[i]) = (animals[i], animals[i + 1])
			i += 1
		elif l != -1:
			print(l, i)
			l = -1
		i += 1
	if l != -1:
		print(l, i)
		l = -1


n = int(input())
L = [int(x) for x in input().split()]
for i in range(n - 1, 0, -1):
	j = i
	i = 1
	while i <= j:
		if L[i] < L[i - 1]:
			print(i, i + 1)
			x = L[i]
			L[i] = L[i - 1]
			L[i - 1] = x
		i += 1


n = int(input())
a = list(map(int, input().strip().split(' ')))
b = sorted(a)
c = []
for i in range(n):
	if a[i] == b[i]:
		continue
	else:
		h = a.index(b[i], i + 1)
		for j in range(h, i, -1):
			li = []
			li.append(j - 1 + 1)
			li.append(j + 1)
			c.append(li)
			t = a[j - 1]
			a[j - 1] = a[j]
			a[j] = t
for i in c:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
ip = list(map(int, input().split()))
ips = sorted(ip)
while ip != ips:
	l = 0
	r = -1
	b = 0
	i = 0
	while i < n - 1:
		if ip[i] > ip[i + 1]:
			r += 2
			i += 2
			b = 1
		elif b == 1:
			break
		else:
			l += 1
			r += 1
			i += 1
	i = l
	while i <= r:
		(ip[i], ip[i + 1]) = (ip[i + 1], ip[i])
		i += 2
	print(l + 1, r + 1)


n = int(input())
l = list(map(int, input().split()))
s = []
for i in range(n):
	for j in range(n - i - 1):
		if l[j] > l[j + 1]:
			s.append((j + 1, j + 2))
			(l[j], l[j + 1]) = (l[j + 1], l[j])
for (i, j) in s:
	print(f'{i} {j}')


n = int(input())
c = list(map(int, input().split()))
while True:
	f = False
	for i in range(1, n):
		if c[i] < c[i - 1]:
			f = True
			(c[i], c[i - 1]) = (c[i - 1], c[i])
			print(i, i + 1)
	if not f:
		break


n = int(input())
z = list(map(int, input().split()))
x = sorted(z)
while x != z:
	c = 0
	while c < n - 1:
		if z[c] <= z[c + 1]:
			c += 1
		else:
			(z[c], z[c + 1]) = (z[c + 1], z[c])
			print(c + 1, c + 2)
			c += 2


n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
	minn = 10000000000
	ind = -1
	for j in range(i, n):
		if arr[j] < minn:
			minn = arr[j]
			ind = j
	arr = arr[:i] + [arr[ind]] + arr[i:ind] + arr[ind + 1:]
	for j in range(ind - 1, i - 1, -1):
		print(j + 1, j + 2)


n = int(input())
l = list(map(int, input().split()))
cmd = []
for i in range(n + 2):
	for j in range(n - 1):
		if l[j] > l[j + 1]:
			cmd.append([j + 1, j + 2])
			(l[j], l[j + 1]) = (l[j + 1], l[j])
for x in cmd:
	print(*x)


n = int(input())
t = list(map(int, input().split()))
for i in range(n):
	a = sorted(((t[j], j) for j in range(n)))
	(x, j) = a[i]
	if j > i:
		for k in range(j, i, -1):
			print(k, k + 1)
			(t[k], t[k - 1]) = (t[k - 1], t[k])


n = int(input())
data = [int(i) for i in input().split()]
ret = ''
while 1:
	p = 0
	for i in range(n - 1):
		if data[i] > data[i + 1]:
			(data[i], data[i + 1]) = (data[i + 1], data[i])
			p += 1
			ret += str(i + 1) + ' ' + str(i + 2) + '\n'
	if not p:
		break
print(ret)


n = int(input())
arr = list(map(int, input().split()))
l = 0
r = n - 1
sort_arr = sorted(arr)
while sort_arr != arr:
	for i in range(1, n):
		if arr[i - 1] > arr[i]:
			l = i - 1
			break
	for i in range(l, n, 2):
		if i + 1 in range(n) and arr[i] > arr[i + 1]:
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			r = i + 1
		else:
			break
	print(l + 1, r + 1)


nn = int(input())
a = list(map(int, input().split()))
for i in range(nn):
	for j in range(nn - i - 1):
		if a[j] > a[j + 1]:
			print(j + 1, j + 2)
			(a[j], a[j + 1]) = (a[j + 1], a[j])


n = int(input())
ans = 0
l = list(map(int, input().split()))
s = sorted(l)
for i in range(n):
	if l[i] != s[i]:
		a = l[i + 1:].index(s[i])
		ind = i + a + 1
		while ind != i:
			print(ind, ind + 1)
			(l[ind - 1], l[ind]) = (l[ind], l[ind - 1])
			ind -= 1


n = int(input())
a = list(map(int, input().split()))
while True:
	update = False
	for l in range(n - 1):
		if a[l] > a[l + 1]:
			(a[l], a[l + 1]) = (a[l + 1], a[l])
			update = True
			print(l + 1, l + 2)
	if update == False:
		break


n = int(input())
a = map(int, input().split(' '))
a = list(a)
ans = []
for j in range(1, n):
	for i in range(n - j):
		if a[i] > a[i + 1]:
			ans.append((i + 1, i + 2))
			(a[i], a[i + 1]) = (a[i + 1], a[i])
for (i, j) in ans:
	print('{} {}'.format(i, j))


n = int(input())
a = list(map(int, input().split()))
ans = []
while True:
	(tl, tr) = (0, 0)
	for i in range(n - 1):
		(tl, tr) = (i, i)
		for j in range(i, n - 1, 2):
			if a[j] > a[j + 1]:
				t = a[j]
				a[j] = a[j + 1]
				a[j + 1] = t
				tr = j + 1
			else:
				break
		if not tl == tr:
			break
	if tl == tr:
		break
	ans.append(str(tl + 1) + ' ' + str(tr + 1))
print('\n'.join(ans))


n = int(input())
v = list(map(int, input().split()))
ok = True
while ok == True:
	ok = False
	for i in range(len(v)):
		if i != len(v) - 1:
			if v[i] > v[i + 1]:
				print('{0} {1}'.format(i + 1, i + 2))
				(v[i], v[i + 1]) = (v[i + 1], v[i])
				ok = True


n = int(input())
tab = list(map(int, input().split()))
for i in range(n):
	for j in range(n - 1):
		if tab[j] > tab[j + 1]:
			(tab[j], tab[j + 1]) = (tab[j + 1], tab[j])
			print(str(j + 1) + ' ' + str(j + 2))


n = int(input())
m = list(map(int, input().split()))
finished = False
while not finished:
	(l, r) = (-1, -1)
	i = 0
	while i < n - 1:
		if m[i] > m[i + 1]:
			if l == -1 or r == -1:
				l = i + 1
				r = i + 2
			else:
				r = i + 2
			(m[i], m[i + 1]) = (m[i + 1], m[i])
			i += 1
		elif m[i] <= m[i + 1]:
			if l != -1 and r != -1:
				print(l, r)
				r = -1
		i += 1
	if l == -1:
		finished = True
	if r != -1 and l != -1:
		print(l, r)
if l != -1 and r != -1:
	print(l, r)


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
n = I()
a = IL()
for i in range(n - 1):
	for j in range(n - 1 - i):
		if a[j] > a[j + 1]:
			print(j + 1, j + 2)
			(a[j], a[j + 1]) = (a[j + 1], a[j])


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	n = int(input())
	s = [int(i) for i in input().split()]
	l = sorted(s)
	d = {}
	nyet = 1
	for i in l:
		if i not in d:
			d[i] = nyet
			nyet += 1
	l = []
	for i in s:
		l.append(d[i])
	ans = []
	for i in range(n):
		m = min(l[i:])
		getind = i + l[i:].index(m)
		if m == l[i]:
			continue
		while getind > i:
			(l[getind], l[getind - 1]) = (l[getind - 1], l[getind])
			ans.append(str(getind) + ' ' + str(getind + 1))
			getind -= 1
	print('\n'.join(ans))
main()


n = int(input())
a = list(map(int, input().split()))
b = a[:]
b.sort()
for i in range(n):
	for j in range(i, n + 1):
		if a[j] == b[i]:
			pos = j
			break
	if i != pos:
		for j in range(pos - i):
			print(pos - j - 1 + 1, pos - j + 1)
			(a[pos - j - 1], a[pos - j]) = (a[pos - j], a[pos - j - 1])


import sys
import math
import bisect

def solve(A):
	n = len(A)
	B = []
	for i in range(n - 1):
		for i in range(n - 1):
			if A[i] > A[i + 1]:
				(A[i], A[i + 1]) = (A[i + 1], A[i])
				B.append([i, i + 1])
	return B

def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = solve(A)
	for p in B:
		l = p[0]
		r = p[1]
		print('%d %d' % (l + 1, r + 1))
main()


n = int(input())
a = [0] + list(map(int, input().split()))

def negs():
	i = 1
	while i < n:
		if a[i] > a[i + 1]:
			yield (i, i + 1)
			i += 1
		i += 1
sorted = False
while not sorted:
	sorted = True
	for pair in negs():
		sorted = False
		(i, j) = (pair[0], pair[1])
		print(i, j)
		(a[i], a[j]) = (a[j], a[i])


a = int(input())
b = list(map(int, input().split()))
for i in range(a):
	for j in range(a - 1):
		if b[j] > b[j + 1]:
			print(j + 1, j + 2)
			x = b[j]
			y = b[j + 1]
			b[j] = y
			b[j + 1] = x


n = int(input())
l = list(map(int, input().split()))
while l != list(sorted(l)):
	for i in range(len(l) - 1):
		if l[i] > l[i + 1]:
			temp = l[i]
			l[i] = l[i + 1]
			l[i + 1] = temp
			print(i + 1, i + 2)


n = int(input())
l = list(map(int, input().split()))
tmp = sorted(l)
i = 1
while l != tmp and i < n:
	if l[i] < l[i - 1]:
		(l[i], l[i - 1]) = (l[i - 1], l[i])
		print(i, i + 1)
		if i == 0 or i == 1:
			i = 0
		else:
			i -= 2
	i += 1


def s(arr):
	arr2 = arr[:]
	arr2.sort()
	return arr == arr2
x = int(input())
y = list(map(int, input().split(' ')))
while not s(y):
	for i in range(x - 1):
		if y[i] > y[i + 1]:
			print(i + 1, i + 2)
			(y[i], y[i + 1]) = (y[i + 1], y[i])


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	s = l[:]
	s.sort()
	if l == s:
		return
	flag = 0
	while s != l:
		i = 1
		while i < n:
			if l[i] < l[i - 1]:
				if not flag:
					left = i
					flag = 1
				right = i + 1
				t = l[i]
				l[i] = l[i - 1]
				l[i - 1] = t
				i += 2
			else:
				if flag:
					stdout.write(str(left) + ' ' + str(right) + '\n')
					flag = 0
				i += 1
		if flag:
			stdout.write(str(left) + ' ' + str(right) + '\n')
			flag = 0
main()


n = int(input())
val = list(map(int, input().split()))
ans = []
srt = sorted(val)

def move(i, j):
	k = i
	while k < j:
		(val[k], val[k + 1]) = (val[k + 1], val[k])
		k += 2

def swap(i, j):
	if i == j:
		return
	elif i == j - 1:
		ans.append((i + 1, j + 1))
		move(i, j)
	else:
		if (i - j + 1) % 2 == 0:
			ans.append((i + 1, j + 1))
			move(i, j)
		else:
			ans.append((i + 1, j))
			move(i, j - 1)
		swap(i + 1, j)
for i in reversed(range(n)):
	for j in range(i + 1):
		if val[j] == srt[i]:
			swap(j, i)
			break
for p in ans:
	print(*p)


n = int(input())
num = list(map(int, input().split()))
ua = list()
ub = list()

def swap(i, j):
	t = num[i]
	num[i] = num[j]
	num[j] = t
ans = 0
for i in range(n - 1, 0, -1):
	for j in range(i):
		if num[j] > num[j + 1]:
			ua.append(j)
			ub.append(j + 1)
			swap(j, j + 1)
			ans += 1
for i in range(ans):
	print(ua[i] + 1, ub[i] + 1)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
n = I()
a = L()
for i in range(n):
	for j in range(n - 1):
		if a[j] > a[j + 1]:
			(a[j], a[j + 1]) = (a[j + 1], a[j])
			print(j + 1, j + 2)


from sys import stdin, stdout
n = int(stdin.readline())
size = list(map(int, stdin.readline().split()))
for i in range(n):
	for j in range(n - i - 1):
		if size[j] > size[j + 1]:
			stdout.write(str(j + 1) + ' ' + str(j + 2) + '\n')
			(size[j], size[j + 1]) = (size[j + 1], size[j])


n = int(input())
data = list(map(int, input().split()))
for k in range(n):
	for i in range(n):
		for j in range(i, -1, -1):
			if data[i] < data[j]:
				(data[i], data[j]) = (data[j], data[i])
				print(j + 1, i + 1)


n = int(input())
a = [0] + list(map(int, input().split()))
i = 1
while i < n:
	j = n - 1
	while j >= i:
		if a[j] > a[j + 1]:
			print(j, j + 1)
			(a[j], a[j + 1]) = (a[j + 1], a[j])
		j -= 1
	i += 1


def swap(a, i, j, verb=False):
	(a[i], a[j]) = (a[j], a[i])
	if verb:
		i += 1
		j += 1
		print(min(i, j), max(i, j))

def cocktail_sort(a, verb=False):
	n = len(a)
	b = 0
	end = False
	while not end:
		end = True
		for i in range(b, n - b - 1):
			if a[i] > a[i + 1]:
				end = False
				swap(a, i, i + 1, verb)
		for i in range(n - b - 1, b, -1):
			if a[i] < a[i - 1]:
				end = False
				swap(a, i - 1, i, verb)
		b += 1
input()
a = list(map(int, input().split()))
cocktail_sort(a, True)


def arr_inp():
	return [int(x) for x in input().split()]
(n, a) = (int(input()), arr_inp())
a_sort = sorted(a)
while a != a_sort:
	(mi, ma, i, flag) = (0, 1, 1, 0)
	while i < n:
		if a[i] < a[i - 1]:
			(a[i], a[i - 1]) = (a[i - 1], a[i])
			ma = i
			i += 2
			flag = 1
		else:
			if flag:
				print(mi + 1, ma + 1)
			i += 1
			(mi, ma, flag) = (i - 1, i, 0)
	if flag:
		print(mi + 1, ma + 1)


n = int(input())
a = list(map(int, input().split()))
ans = []
cnt = 0
while a != sorted(a):
	cnt = 0
	while cnt < len(a):
		if cnt != len(a) - 1 and a[cnt] > a[cnt + 1]:
			ans.append([cnt + 1, cnt + 2])
			(a[cnt], a[cnt + 1]) = (a[cnt + 1], a[cnt])
			cnt += 2
		else:
			cnt += 1
for i in ans:
	print(*i)


n = int(input())
l = list(map(int, input().split()))
l1 = sorted(l)
k = 0
for i in range(n - 1, -1, -1):
	p = l.index(l1[i])
	l.append(l[p])
	del l[p]
	for i in range(p, n - k - 1):
		print(i + 1, i + 2)
	k = k + 1


n = int(input())
a = list(map(int, input().split()))

def swap(i):
	global a
	x = a[i]
	a[i] = a[i + 1]
	a[i + 1] = x
	print(i + 1, i + 2)
c = True
while c:
	c = False
	for i in range(n):
		if i < n - 1 and a[i] > a[i + 1]:
			swap(i)
			c = True


def swap(l, r):
	k = l
	while k < r:
		tmp = a[k]
		a[k] = a[k + 1]
		a[k + 1] = tmp
		k += 2
n = int(input())
a = list(map(int, input().split()))
asorted = False
while not asorted:
	h = [a[i] - a[i + 1] for i in range(n - 1)]
	c = [0, 0]
	for i in range(n - 1):
		if h[i] > 0:
			c[i % 2] += 1
	if c[0] > c[1]:
		i = 0
	else:
		i = 1
	l = -1
	while i < n - 1:
		if h[i] > 0:
			if l == -1:
				l = i
		if h[i] < 0:
			if l > -1:
				r = i - 1
				print(l + 1, r + 1)
				swap(l, r)
				l = -1
		i += 2
	if l > -1:
		if n % 2 == 0:
			if c[0] > c[1]:
				r = n - 1
			else:
				r = n - 2
		elif c[0] > c[1]:
			r = n - 2
		else:
			r = n - 1
		print(l + 1, r + 1)
		swap(l, r)
	asorted = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			asorted = False
			break


n = int(input())
arr = [int(x) for x in input().split(' ')]
while True:
	change = False
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			change = True
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			print(i + 1, i + 2)
	if not change:
		break


n = int(input())
arr = input().split()
ans = []
for i in range(len(arr)):
	arr[i] = int(arr[i])
for i in range(n - 1, 0, -1):
	for j in range(i):
		if arr[j] > arr[j + 1]:
			(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
			ans.append(j + 1)
			ans.append(j + 2)
for i in range(0, len(ans), 2):
	print(ans[i], ans[i + 1])


n = map(int, input().split())
numbers = list(map(int, input().split()))
for i in range(len(numbers)):
	for i in range(len(numbers)):
		if i != len(numbers) - 1 and numbers[i] > numbers[i + 1]:
			tmp = numbers[i]
			numbers[i] = numbers[i + 1]
			numbers[i + 1] = tmp
			print(i + 1, i + 2, sep=' ')


numAnimals = int(input())
goal = input().split()
for i in range(numAnimals):
	goal[i] = int(goal[i])
animals = []
for i in goal:
	animals.append(i)
goal.sort()
for i in range(numAnimals):
	if animals[0] != goal[i]:
		while animals[0] != goal[i]:
			currentposition = animals.index(goal[i])
			print(str(currentposition + i), str(currentposition + 1 + i))
			temp = animals[currentposition - 1]
			animals[currentposition - 1] = animals[currentposition]
			animals[currentposition] = temp
		animals = animals[1:]
	else:
		animals = animals[1:]
		continue


n = int(input())
a = [int(x) for x in input().split()]
is_sorted = False
while not is_sorted:
	is_sorted = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			is_sorted = False
			print(i + 1, i + 2)
			(a[i], a[i + 1]) = (a[i + 1], a[i])


import sys, bisect
n = int(input())
lst = list(map(int, sys.stdin.readline().split()))
num = [0 for i in range(n)]
for i in range(n):
	num[i] = lst[i]
num.sort(reverse=True)
for i in range(n):
	for j in range(n - i):
		if lst[j] == num[i]:
			a = j
			break
	for j in range(a, n - i - 1):
		print(j + 1, j + 2)
		(lst[j], lst[j + 1]) = (lst[j + 1], lst[j])


n = int(input())
arr = list(map(int, input().split()))
check = 0
while check == 0:
	check = 1
	i = 0
	while i < n - 1:
		if arr[i] > arr[i + 1]:
			check = 0
			print(i + 1, i + 2)
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		i += 1


n = int(input())
f = input().split()
for i in range(n):
	f[i] = int(f[i])
t = 0
while t == 0:
	t = 1
	for i in range(n - 1):
		if f[i] > f[i + 1]:
			print(i + 1, i + 2)
			p = f[i]
			f[i] = f[i + 1]
			f[i + 1] = p
			t = 0


input()
a = list(map(int, input().split()))

def bubble_sort(a):
	for i in reversed(range(len(a))):
		for j in range(1, i + 1):
			if a[j - 1] > a[j]:
				print(j, j + 1)
				(a[j], a[j - 1]) = (a[j - 1], a[j])
bubble_sort(a)


n = int(input())
arr = list(map(int, input().split()))
temp = arr.copy()
temp.sort()
res = ''
for i in range(n):
	k1 = arr.index(temp[n - i - 1])
	y = k1 + 1
	while y < n - i:
		res += str(y) + ' ' + str(y + 1) + '\n'
		(arr[y], arr[y - 1]) = (arr[y - 1], arr[y])
		y += 1
print(res)


def get_ints():
	return list(map(int, input().split()))

def swap(a, l, r):
	for i in range(l, r, 2):
		(a[i], a[i + 1]) = (a[i + 1], a[i])

def main():
	n = int(input())
	a = get_ints()
	logs = []
	while True:
		i = 0
		(l, r) = (None, None)
		while i < n - 1:
			if a[i] > a[i + 1]:
				if l is None:
					l = i
				r = i + 1
				i += 2
			else:
				i += 1
		if l is not None:
			if l % 2 == r % 2:
				r -= 1
			swap(a, l, r)
			logs.append((l, r))
		if l is None:
			break
	print('\n'.join(map(lambda x: '{} {}'.format(x[0] + 1, x[1] + 1), logs)))
main()


def main():
	n = int(input())
	seq = [int(c) for c in input().split()]
	ans = []
	m = n - 1
	while m > 0:
		for i in range(m):
			if seq[i + 1] < seq[i]:
				(seq[i + 1], seq[i]) = (seq[i], seq[i + 1])
				ans.append((i + 1, i + 2))
		m -= 1
	out = []
	for e in ans:
		out.append('%d %d' % e)
	print('\n'.join(out))
main()


n = int(input())
p = input()
a = [int(i) for i in p.split()]
for k in range(n):
	for i in range(n):
		if i + 1 < n and a[i] > a[i + 1]:
			l = -1
			r = -1
			for j in range(i, n, 2):
				if j + 1 < n:
					if a[j] > a[j + 1] and l == -1:
						l = j + 1
						r = j + 2
						(a[j], a[j + 1]) = (a[j + 1], a[j])
					elif a[j] > a[j + 1] and l != -1:
						r = j + 2
						(a[j], a[j + 1]) = (a[j + 1], a[j])
					elif l != -1:
						print(l, end=' ')
						print(r)
						l = -1
						r = -1
			if l != -1:
				print(l, end=' ')
				print(r)
				l = -1


n = int(input())
a = [int(i) for i in input().split()]
d = []
for i in range(n - 1):
	for j in range(n - 1):
		if a[j] > a[j + 1]:
			d.append((j + 1, j + 2))
			(a[j], a[j + 1]) = (a[j + 1], a[j])
for i in d:
	print(i[0], i[1])


import sys
n = int(input())
arr = list(map(int, input().split()))

def f(arr, a):
	on = 0
	for i in range(len(a)):
		if i == len(a) - 1:
			if not on:
				print(a[i][0], a[i][1])
			else:
				print(a[i][1])
			break
		if a[i][1] == a[i + 1][0] - 1:
			if not on:
				print(a[i][0], end=' ')
				on = 1
		elif on:
			on = 0
			print(a[i][1])
		else:
			print(a[i][0], a[i][1])
	for i in range(len(a)):
		(arr[a[i][0] - 1], arr[a[i][1] - 1]) = (arr[a[i][1] - 1], arr[a[i][0] - 1])

def sort(n, arr):
	a = []
	t = []
	if n % 2:
		(p, q) = (n - 2, n - 1)
	else:
		(p, q) = (n - 1, n - 2)
	for i in range(0, p, 2):
		if arr[i] > arr[i + 1]:
			a.append([i + 1, i + 2])
	for i in range(1, q, 2):
		if arr[i] > arr[i + 1]:
			t.append([i + 1, i + 2])
	if len(a) == 0 and len(t) == 0:
		sys.exit()
	f(arr, a)
	f(arr, t)
for i in range(n):
	sort(n, arr)


def zoo(lst):
	result = list()
	for i in range(len(lst) + 2):
		for j in range(len(lst) - 1):
			if lst[j] > lst[j + 1]:
				result.append([j + 1, j + 2])
				(lst[j], lst[j + 1]) = (lst[j + 1], lst[j])
	return result
n = int(input())
a = [int(x) for x in input().split()]
for elem in zoo(a):
	print(*elem)


n = int(input())
a = [int(x) for x in input().split()]
b = sorted(a)
for i in range(n):
	mini = b[i]
	for j in range(i + 1, n):
		if a[j] == mini:
			for k in range(j, i, -1):
				print(k, k + 1)
				(a[k], a[k - 1]) = (a[k - 1], a[k])
			break


import sys
n = int(input())
an = list(map(int, sys.stdin.readline().split()))
ans = []
while True:
	left = 0
	right = 0
	while left + 1 < n and an[left] <= an[left + 1]:
		left += 1
	if left + 1 >= n:
		break
	right = left + 2
	while right + 1 < n and an[right] >= an[right + 1]:
		right += 2
	i = left
	while i + 1 < right:
		(an[i], an[i + 1]) = (an[i + 1], an[i])
		i += 2
	ans.append((left + 1, right))
for i in range(len(ans)):
	print(ans[i][0], ans[i][1])


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	for t in range(i - 1, -1, -1):
		if a[t] > a[t + 1]:
			(a[t], a[t + 1]) = (a[t + 1], a[t])
			print(t + 1, t + 2)


def main():
	n = int(input())
	height = list(map(int, input().split()))
	for i in range(n - 1, 0, -1):
		for j in range(i):
			if height[j] > height[j + 1]:
				(height[j], height[j + 1]) = (height[j + 1], height[j])
				print(j + 1, j + 2)
main()


n = int(input())
l = list(map(int, input().split()))
ans = []
ls = sorted(l)
while l != ls:
	for i in range(1, n):
		if l[i - 1] > l[i]:
			ans += [' '.join([str(i), str(i + 1)])]
			(l[i - 1], l[i]) = (l[i], l[i - 1])
print('\n'.join(ans))


n = int(input())
vals = list(map(int, input().split()))
so = list(sorted(vals))
while vals != so:
	i = 0
	while i < n - 1:
		if vals[i] > vals[i + 1]:
			(vals[i], vals[i + 1]) = (vals[i + 1], vals[i])
			j = i + 2
			while j < n - 1 and vals[j] > vals[j + 1]:
				(vals[j], vals[j + 1]) = (vals[j + 1], vals[j])
				j += 2
			print(i + 1, j)
		else:
			i += 1


from copy import *
n = int(input())
arr = list(map(int, input().split()))
arr1 = copy(arr)
arr1.sort()
for i in range(n):
	k1 = arr.index(arr1[n - i - 1])
	y = k1 + 1
	while y != n - i:
		print(y, y + 1)
		temp = arr[y - 1]
		arr[y - 1] = arr[y]
		arr[y] = temp
		y += 1


def issorted(a):
	p = 0
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			p += 1
			break
	if p == 1:
		return False
	else:
		return True
n = int(input())
a = list(map(int, input().split()))
c = []
while True:
	if issorted(a) == False:
		for i in range(len(a) - 1):
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				c.append([i + 1, i + 2])
	else:
		break
for i in range(len(c)):
	print(*c[i])


import time

def test(a, n):
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			return False
	return True

def ch(a, l, r):
	i = l
	while i < r:
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		i = i + 2
	return a
n = int(input())
a = [int(i) for i in input().split()]
ans = []
start = time.time()
while test(a, n) == False:
	i = 0
	while a[i] <= a[i + 1]:
		i = i + 1
		if i == n:
			break
	j = i
	while a[j] > a[j + 1]:
		j = j + 2
		if j > n - 2:
			break
	a = ch(a, i, j)
	ans.append([i + 1, j])
for i in ans:
	print(i[0], i[1])
finish = time.time()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	n = scanner()
	a = get_list()
	for i in range(n - 1, -1, -1):
		for j in range(i):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				print(j + 1, j + 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
for i in range(t):
	solve()


n = int(input())
arr = list(map(int, input().split()))
for i in range(1, n):
	if arr[i] < arr[i - 1]:
		j = i
		while j > 0 and arr[j - 1] > arr[j]:
			print(j, j + 1)
			tmp = arr[j - 1]
			arr[j - 1] = arr[j]
			arr[j] = tmp
			j -= 1


n = int(input())
tailles = list(map(int, input().split()))
a = 1
while a != -1:
	a = -1
	b = -1
	i = 0
	while i != n - 1 and tailles[i + 1] >= tailles[i]:
		i += 1
	if i != n - 1:
		a = 1
		print(i + 1, i + 2)
		(tailles[i], tailles[i + 1]) = (tailles[i + 1], tailles[i])