n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
 for j in range(0,n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];c+=1
print(*a)
print(c) n=int(input()) n int(input()) int input() input a=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c=0 c 0 for i in range(n-1):
 for j in range(0,n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];c+=1 i range(n-1) range n-1 n 1 for j in range(0,n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];c+=1 j range(0,n-i-1) range 0 n-i-1 n-i n i 1 if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];c+ a[j]>a[j+1] a[j] a j a[j+1] a j+1 j 1 print(*a) print *a a print(c) print c n=int(input()) int(input()) n a=list(map(int,input().split())) list(map(int,input().split())) a c=0 0 c
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
 for j in range(0,n-i-1):
  if a[j]>a[j+1]:a[j],a[j+1]=a[j+1],a[j];c+=1
print(*a)
print(c)
