N = input()
n = map(int,raw_input().split(' '))
c = 0
for i in range(0,N-1):
	for j in range(1,N-i):
		if n[j-1] > n[j]:
			temp = n[j-1]
			n[j-1] = n[j]
			n[j] = temp
			c += 1
print " ".join(str(i) for i in n)
print c N = input() N input() input n = map(int,raw_input().split(' ')) n map(int,raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' c = 0 c 0 for i in range(0,N-1):
	for j in range(1,N-i):
		if n[j-1] > n[j]:
			temp = n[j-1]
			n[j-1] = n[j]
			n[j] = temp
			c += 1 i range(0,N-1) range 0 N-1 N 1 for j in range(1,N-i):
		if n[j-1] > n[j]:
			temp = n[j-1]
			n[j-1] = n[j]
			n[j] = temp
			c += 1 j range(1,N-i) range 1 N-i N i if n[j-1] > n[j]:
			temp = n[j-1]
			n[j-1] = n[j]
			n[j] = temp
			c += 1 n[j-1] > n[j] n[j-1] n j-1 j 1 n[j] n j temp = n[j-1] temp n[j-1] n j-1 j 1 n[j-1] = n[j] n[j-1] n j-1 j 1 n[j] n j n[j] = temp n[j] n j temp c += 1 c 1 print " ".join(str(i) for i in n) " ".join " " join str(i) str i print N = input() input() N n = map(int,raw_input().split(' ')) map(int,raw_input().split(' ')) n c += 1 1 c temp = n[j-1] n[j-1] temp c = 0 0 c
N = input()
n = map(int,raw_input().split(' '))
c = 0
for i in range(0,N-1):
	for j in range(1,N-i):
		if n[j-1] > n[j]:
			temp = n[j-1]
			n[j-1] = n[j]
			n[j] = temp
			c += 1
print " ".join(str(i) for i in n)
print c