n = int(input())
data = [int(s) for s in input().split()]

change = 0
flag = True
while flag:
	flag = False
	for idx in range(1,n):
		if data[idx-1] > data[idx]:
			data[idx-1],data[idx] = data[idx],data[idx-1]
			flag = True
			change += 1

print(' '.join([str(d) for d in data]))
print(change) n = int(input()) n int(input()) int input() input int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s data = [int(s) for s in input().split()] data [int(s) for s in input().split()] change = 0 change 0 flag = True flag True while flag:
	flag = False
	for idx in range(1,n):
		if data[idx-1] > data[idx]:
			data[idx-1],data[idx] = data[idx],data[idx-1]
			flag = True
			change += 1 flag flag = False flag False for idx in range(1,n):
		if data[idx-1] > data[idx]:
			data[idx-1],data[idx] = data[idx],data[idx-1]
			flag = True
			change += 1 idx range(1,n) range 1 n if data[idx-1] > data[idx]:
			data[idx-1],data[idx] = data[idx],data[idx-1]
			flag = True
			change += 1 data[idx-1] > data[idx] data[idx-1] data idx-1 idx 1 data[idx] data idx data[idx-1],data[idx] = data[idx],data[idx-1] data[idx-1] data idx-1 idx 1 data[idx] data idx data[idx] data idx data[idx-1] data idx-1 idx 1 flag = True flag True change += 1 change 1 str(d) for d in data for d in data d data for d in data str(d) str d print(' '.join([str(d) for d in data])) print ' '.join([str(d) for d in data]) ' '.join ' ' join [str(d) for d in data] print(change) print change change += 1 1 change flag = False False flag flag = True True flag n = int(input()) int(input()) n change = 0 0 change flag = True True flag data = [int(s) for s in input().split()] [int(s) for s in input().split()] data
n = int(input())
data = [int(s) for s in input().split()]

change = 0
flag = True
while flag:
	flag = False
	for idx in range(1,n):
		if data[idx-1] > data[idx]:
			data[idx-1],data[idx] = data[idx],data[idx-1]
			flag = True
			change += 1

print(' '.join([str(d) for d in data]))
print(change)