n = int(raw_input())
a = map(int, raw_input().split())

temp = 0
cnt = 0
for i in range(n):
	for j in range(n-i-1):
		if a[j] > a[j+1]:
			temp = a[j]
			a[j] = a[j+1]
			a[j+1] = temp
			cnt += 1

for i in range(n):
	if i != n-1:
		print(a[i]),
	else:
		print(a[i])

print cnt n = int(raw_input()) n int(raw_input()) int raw_input() raw_input a = map(int, raw_input().split()) a map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split temp = 0 temp 0 cnt = 0 cnt 0 for i in range(n):
	for j in range(n-i-1):
		if a[j] > a[j+1]:
			temp = a[j]
			a[j] = a[j+1]
			a[j+1] = temp
			cnt += 1 i range(n) range n for j in range(n-i-1):
		if a[j] > a[j+1]:
			temp = a[j]
			a[j] = a[j+1]
			a[j+1] = temp
			cnt += 1 j range(n-i-1) range n-i-1 n-i n i 1 if a[j] > a[j+1]:
			temp = a[j]
			a[j] = a[j+1]
			a[j+1] = temp
			cnt += 1 a[j] > a[j+1] a[j] a j a[j+1] a j+1 j 1 temp = a[j] temp a[j] a j a[j] = a[j+1] a[j] a j a[j+1] a j+1 j 1 a[j+1] = temp a[j+1] a j+1 j 1 temp cnt += 1 cnt 1 for i in range(n):
	if i != n-1:
		print(a[i]),
	else:
		print(a[i]) i range(n) range n if i != n-1:
		print(a[i]),
	else:
		print(a[i]) i != n-1 i n-1 n 1 print(a[i]) print a[i] a i print(a[i]) print a[i] a i print temp = a[j] a[j] temp n = int(raw_input()) int(raw_input()) n cnt = 0 0 cnt temp = 0 0 temp a = map(int, raw_input().split()) map(int, raw_input().split()) a cnt += 1 1 cnt
n = int(raw_input())
a = map(int, raw_input().split())

temp = 0
cnt = 0
for i in range(n):
	for j in range(n-i-1):
		if a[j] > a[j+1]:
			temp = a[j]
			a[j] = a[j+1]
			a[j+1] = temp
			cnt += 1

for i in range(n):
	if i != n-1:
		print(a[i]),
	else:
		print(a[i])

print cnt