n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(0,n):
	for j in range(i+1,n)[::-1]:
		if a[j]<a[j-1]:
			a[j],a[j-1] = a[j-1],a[j]
			cnt += 1
print(" ".join(map(str,a)))
print(cnt) 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 cnt = 0 cnt 0 for i in range(0,n):
	for j in range(i+1,n)[::-1]:
		if a[j]<a[j-1]:
			a[j],a[j-1] = a[j-1],a[j]
			cnt += 1 i range(0,n) range 0 n for j in range(i+1,n)[::-1]:
		if a[j]<a[j-1]:
			a[j],a[j-1] = a[j-1],a[j]
			cnt += 1 j range(i+1,n)[::-1] (i+1,n) range i+1 i 1 n ::-1 -1 if a[j]<a[j-1]:
			a[j],a[j-1] = a[j-1],a[j]
			cnt += 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 cnt += 1 cnt 1 print(" ".join(map(str,a))) print " ".join(map(str,a)) " ".join " " join map(str,a) map str a print(cnt) print cnt a = list(map(int,input().split())) list(map(int,input().split())) a n = int(input()) int(input()) n cnt = 0 0 cnt cnt += 1 1 cnt
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(0,n):
	for j in range(i+1,n)[::-1]:
		if a[j]<a[j-1]:
			a[j],a[j-1] = a[j-1],a[j]
			cnt += 1
print(" ".join(map(str,a)))
print(cnt)