numbers = []
n = int(raw_input())
s = raw_input()
count = 0

numbers = s.split(" ")
for i in range(int(n)):
	numbers[i] = int(numbers[i])

flag = 1
while flag:
	flag = 0
	for j in range(n - 1, 0, -1):
		if numbers[j] < numbers[j - 1]:
			numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
			flag = 1
			count += 1
print ' '.join([str(a) for a in numbers])
print count numbers = [] numbers [] n = int(raw_input()) n int(raw_input()) int raw_input() raw_input s = raw_input() s raw_input() raw_input count = 0 count 0 numbers = s.split(" ") numbers s.split(" ") s.split s split " " for i in range(int(n)):
	numbers[i] = int(numbers[i]) i range(int(n)) range int(n) int n numbers[i] = int(numbers[i]) numbers[i] numbers i int(numbers[i]) int numbers[i] numbers i flag = 1 flag 1 while flag:
	flag = 0
	for j in range(n - 1, 0, -1):
		if numbers[j] < numbers[j - 1]:
			numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
			flag = 1
			count += 1 flag flag = 0 flag 0 for j in range(n - 1, 0, -1):
		if numbers[j] < numbers[j - 1]:
			numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
			flag = 1
			count += 1 j range(n - 1, 0, -1) range n - 1 n 1 0 -1 if numbers[j] < numbers[j - 1]:
			numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
			flag = 1
			count += 1 numbers[j] < numbers[j - 1] numbers[j] numbers j numbers[j - 1] numbers j - 1 j 1 numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j] numbers[j] numbers j numbers[j - 1] numbers j - 1 j 1 numbers[j - 1] numbers j - 1 j 1 numbers[j] numbers j flag = 1 flag 1 count += 1 count 1 print str(a) for a in numbers for a in numbers a numbers for a in numbers str(a) str a ' '.join([str(a) for a in numbers]) ' '.join ' ' join [str(a) for a in numbers] print numbers = s.split(" ") s.split(" ") numbers count += 1 1 count count = 0 0 count flag = 1 1 flag numbers = [] [] numbers flag = 1 1 flag flag = 0 0 flag n = int(raw_input()) int(raw_input()) n s = raw_input() raw_input() s
numbers = []
n = int(raw_input())
s = raw_input()
count = 0

numbers = s.split(" ")
for i in range(int(n)):
	numbers[i] = int(numbers[i])

flag = 1
while flag:
	flag = 0
	for j in range(n - 1, 0, -1):
		if numbers[j] < numbers[j - 1]:
			numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
			flag = 1
			count += 1
print ' '.join([str(a) for a in numbers])
print count