n = int(input())
li = list(map(int, input().split()))
cnt = 0

flag = True

while flag:
	flag = False
	for i in range(n-1,0,-1):
		if li[i] < li[i-1]:
			li[i], li[i-1] = li[i-1], li[i]
			flag = True
			cnt +=1

print(*li)
print(cnt) n = int(input()) n int(input()) int input() input li = list(map(int, input().split())) li list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 flag = True flag True while flag:
	flag = False
	for i in range(n-1,0,-1):
		if li[i] < li[i-1]:
			li[i], li[i-1] = li[i-1], li[i]
			flag = True
			cnt +=1 flag flag = False flag False for i in range(n-1,0,-1):
		if li[i] < li[i-1]:
			li[i], li[i-1] = li[i-1], li[i]
			flag = True
			cnt +=1 i range(n-1,0,-1) range n-1 n 1 0 -1 if li[i] < li[i-1]:
			li[i], li[i-1] = li[i-1], li[i]
			flag = True
			cnt +=1 li[i] < li[i-1] li[i] li i li[i-1] li i-1 i 1 li[i], li[i-1] = li[i-1], li[i] li[i] li i li[i-1] li i-1 i 1 li[i-1] li i-1 i 1 li[i] li i flag = True flag True cnt +=1 cnt 1 print(*li) print *li li print(cnt) print cnt n = int(input()) int(input()) n cnt = 0 0 cnt flag = True True flag cnt +=1 1 cnt flag = True True flag flag = False False flag li = list(map(int, input().split())) list(map(int, input().split())) li
n = int(input())
li = list(map(int, input().split()))
cnt = 0

flag = True

while flag:
	flag = False
	for i in range(n-1,0,-1):
		if li[i] < li[i-1]:
			li[i], li[i-1] = li[i-1], li[i]
			flag = True
			cnt +=1

print(*li)
print(cnt)