N=input()
A=map(int,raw_input().split())
num=0
flag=1
while flag:
	flag=0
	for j in reversed(range(N-1)):
		if A[j+1]<A[j]:
			A[j+1],A[j]=A[j],A[j+1]
			flag=1
			num+=1

for m in range(N-1):
	print str(A[m]),
print A[N-1]
print num N=input() N input() input A=map(int,raw_input().split()) A map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split num=0 num 0 flag=1 flag 1 while flag:
	flag=0
	for j in reversed(range(N-1)):
		if A[j+1]<A[j]:
			A[j+1],A[j]=A[j],A[j+1]
			flag=1
			num+=1 flag flag=0 flag 0 for j in reversed(range(N-1)):
		if A[j+1]<A[j]:
			A[j+1],A[j]=A[j],A[j+1]
			flag=1
			num+=1 j reversed(range(N-1)) reversed range(N-1) range N-1 N 1 if A[j+1]<A[j]:
			A[j+1],A[j]=A[j],A[j+1]
			flag=1
			num+=1 A[j+1]<A[j] A[j+1] A j+1 j 1 A[j] A j A[j+1],A[j]=A[j],A[j+1] A[j+1] A j+1 j 1 A[j] A j A[j] A j A[j+1] A j+1 j 1 flag=1 flag 1 num+=1 num 1 for m in range(N-1):
	print str(A[m]), m range(N-1) range N-1 N 1 print str(A[m]) str A[m] A m print A[N-1] A N-1 N 1 print num=0 0 num flag=1 1 flag N=input() input() N flag=1 1 flag flag=0 0 flag A=map(int,raw_input().split()) map(int,raw_input().split()) A num+=1 1 num
N=input()
A=map(int,raw_input().split())
num=0
flag=1
while flag:
	flag=0
	for j in reversed(range(N-1)):
		if A[j+1]<A[j]:
			A[j+1],A[j]=A[j],A[j+1]
			flag=1
			num+=1

for m in range(N-1):
	print str(A[m]),
print A[N-1]
print num