N = int(input())
A = list(map(int, input().split()))

flag = 1
counter = 0
while flag:
	flag = 0
	for i in reversed(range(1,N)):
		if A[i] < A[i-1]:
			A[i], A[i-1] = A[i-1], A[i]
			counter += 1
			flag = 1
print(" ".join(map(str, A)))
print(counter) N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split flag = 1 flag 1 counter = 0 counter 0 while flag:
	flag = 0
	for i in reversed(range(1,N)):
		if A[i] < A[i-1]:
			A[i], A[i-1] = A[i-1], A[i]
			counter += 1
			flag = 1 flag flag = 0 flag 0 for i in reversed(range(1,N)):
		if A[i] < A[i-1]:
			A[i], A[i-1] = A[i-1], A[i]
			counter += 1
			flag = 1 i reversed(range(1,N)) reversed range(1,N) range 1 N if A[i] < A[i-1]:
			A[i], A[i-1] = A[i-1], A[i]
			counter += 1
			flag = 1 A[i] < A[i-1] A[i] A i A[i-1] A i-1 i 1 A[i], A[i-1] = A[i-1], A[i] A[i] A i A[i-1] A i-1 i 1 A[i-1] A i-1 i 1 A[i] A i counter += 1 counter 1 flag = 1 flag 1 print(" ".join(map(str, A))) print " ".join(map(str, A)) " ".join " " join map(str, A) map str A print(counter) print counter flag = 0 0 flag flag = 1 1 flag counter += 1 1 counter flag = 1 1 flag counter = 0 0 counter N = int(input()) int(input()) N A = list(map(int, input().split())) list(map(int, input().split())) A
N = int(input())
A = list(map(int, input().split()))

flag = 1
counter = 0
while flag:
	flag = 0
	for i in reversed(range(1,N)):
		if A[i] < A[i-1]:
			A[i], A[i-1] = A[i-1], A[i]
			counter += 1
			flag = 1
print(" ".join(map(str, A)))
print(counter)