num = int(input())
A = list(map(int,input().split(" ")))
chg = 0
for i in range(num):
	for j in range(num-1,i,-1):
		if A[j] < A[j-1]:
			A[j],A[j-1] = A[j-1],A[j]
			chg += 1
print(*A)
print(chg)
 num = int(input()) num 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 " " chg = 0 chg 0 for i in range(num):
	for j in range(num-1,i,-1):
		if A[j] < A[j-1]:
			A[j],A[j-1] = A[j-1],A[j]
			chg += 1 i range(num) range num for j in range(num-1,i,-1):
		if A[j] < A[j-1]:
			A[j],A[j-1] = A[j-1],A[j]
			chg += 1 j range(num-1,i,-1) range num-1 num 1 i -1 if A[j] < A[j-1]:
			A[j],A[j-1] = A[j-1],A[j]
			chg += 1 A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j],A[j-1] = A[j-1],A[j] A[j] A j A[j-1] A j-1 j 1 A[j-1] A j-1 j 1 A[j] A j chg += 1 chg 1 print(*A) print *A A print(chg) print chg A = list(map(int,input().split(" "))) list(map(int,input().split(" "))) A chg += 1 1 chg chg = 0 0 chg num = int(input()) int(input()) num
num = int(input())
A = list(map(int,input().split(" ")))
chg = 0
for i in range(num):
	for j in range(num-1,i,-1):
		if A[j] < A[j-1]:
			A[j],A[j-1] = A[j-1],A[j]
			chg += 1
print(*A)
print(chg)

