def bubble(l):
	count = 0
	N = len(l)
	flag = 1

	while flag:
		flag = 0
		for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	return l, count


if __name__ == '__main__':
	n = int(input())
	l = input().split()

	for i in range(n):
		l[i] = int(l[i])

	l, c = bubble(l)
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)
			print(c)
 def bubble(l):
	count = 0
	N = len(l)
	flag = 1

	while flag:
		flag = 0
		for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	return l, count bubble count = 0 count 0 N = len(l) N len(l) len l flag = 1 flag 1 while flag:
		flag = 0
		for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	 flag flag = 0 flag 0 for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	 j range(N - 1, 1 - 1, -1) range N - 1 N 1 1 - 1 1 1 -1 if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	 l[j] < l[j - 1] l[j] l j l[j - 1] l j - 1 j 1 l[j], l[j - 1] = l[j - 1], l[j] l[j] l j l[j - 1] l j - 1 j 1 l[j - 1] l j - 1 j 1 l[j] l j flag = 1 flag 1 count += 1 count 1 return l, count return l, count l count l l if __name__ == '__main__':
	n = int(input())
	l = input().split()

	for i in range(n):
		l[i] = int(l[i])

	l, c = bubble(l)
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)
			print(c) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input l = input().split() l input().split() ().split () input split for i in range(n):
		l[i] = int(l[i])

	 i range(n) range n l[i] = int(l[i]) l[i] l i int(l[i]) int l[i] l i l, c = bubble(l) l bubble(l) bubble l c count = 0 count 0 leng = len(l) leng len(l) len l for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)
			print(c) i l count += 1 count 1 if count < leng:
			print(i, end =' ')
		else:
			print(i)
			print(c) count < leng count leng print(i, end =' ') print i end =' ' end ' ' print(i) print i print(c) print c def bubble(l):
	count = 0
	N = len(l)
	flag = 1

	while flag:
		flag = 0
		for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	return l, count def bubble(l):
	count = 0
	N = len(l)
	flag = 1

	while flag:
		flag = 0
		for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	return l, count bubble leng = len(l) len(l) leng l = input().split() input().split() l count = 0 0 count l, c = bubble(l) bubble(l) l n = int(input()) int(input()) n count += 1 1 count c = bubble(l) bubble(l) c
def bubble(l):
	count = 0
	N = len(l)
	flag = 1

	while flag:
		flag = 0
		for j in range(N - 1, 1 - 1, -1):
			if l[j] < l[j - 1]:
				l[j], l[j - 1] = l[j - 1], l[j]
				flag = 1
				count += 1

	return l, count


if __name__ == '__main__':
	n = int(input())
	l = input().split()

	for i in range(n):
		l[i] = int(l[i])

	l, c = bubble(l)
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)
			print(c)

