NN=raw_input()
N=raw_input()
A = [int(i) for i in N.split()]
swap=0

for i in range(int(NN)):
  for j in reversed(range(i+1,int(NN))):
    if A[j] < A[j-1] :
      t = A[j]
      A[j] = A[j-1]
      A[j-1] = t
      swap+=1
      
print ' '.join([str(k) for k in A])
print swap NN=raw_input() NN raw_input() raw_input N=raw_input() N raw_input() raw_input int(i) for i in N.split() for i in N.split() i N.split() N.split N split for i in N.split() int(i) int i A = [int(i) for i in N.split()] A [int(i) for i in N.split()] swap=0 swap 0 for i in range(int(NN)):
  for j in reversed(range(i+1,int(NN))):
    if A[j] < A[j-1] :
      t = A[j]
      A[j] = A[j-1]
      A[j-1] = t
      swap+=1
       i range(int(NN)) range int(NN) int NN for j in reversed(range(i+1,int(NN))):
    if A[j] < A[j-1] :
      t = A[j]
      A[j] = A[j-1]
      A[j-1] = t
      swap+=1
       j reversed(range(i+1,int(NN))) reversed range(i+1,int(NN)) range i+1 i 1 int(NN) int NN if A[j] < A[j-1] :
      t = A[j]
      A[j] = A[j-1]
      A[j-1] = t
      swap+=1
       A[j] < A[j-1] A[j] A j A[j-1] A j-1 j 1 t = A[j] t A[j] A j A[j] = A[j-1] A[j] A j A[j-1] A j-1 j 1 A[j-1] = t A[j-1] A j-1 j 1 t swap+=1 swap 1 print str(k) for k in A for k in A k A for k in A str(k) str k ' '.join([str(k) for k in A]) ' '.join ' ' join [str(k) for k in A] print NN=raw_input() raw_input() NN A = [int(i) for i in N.split()] [int(i) for i in N.split()] A t = A[j] A[j] t swap=0 0 swap swap+=1 1 swap N=raw_input() raw_input() N
NN=raw_input()
N=raw_input()
A = [int(i) for i in N.split()]
swap=0

for i in range(int(NN)):
  for j in reversed(range(i+1,int(NN))):
    if A[j] < A[j-1] :
      t = A[j]
      A[j] = A[j-1]
      A[j-1] = t
      swap+=1
      
print ' '.join([str(k) for k in A])
print swap