count = 0
list1 = []

a = int(input())
list1  = list(map(int, input(). split()))

for i in range(len(list1)):
  for n in range(len(list1) - i - 1):
    if(list1[n] > list1[n + 1]):
      tmp = list1[n]
      list1[n] = list1[n + 1]
      list1[n + 1] = tmp
      count += 1

print(" ".join(str(x) for x in list1))
print(count) count = 0 count 0 list1 = [] list1 [] a = int(input()) a int(input()) int input() input list1  = list(map(int, input(). split())) list1 list(map(int, input(). split())) list map(int, input(). split()) map int input(). split() (). split () input split for i in range(len(list1)):
  for n in range(len(list1) - i - 1):
    if(list1[n] > list1[n + 1]):
      tmp = list1[n]
      list1[n] = list1[n + 1]
      list1[n + 1] = tmp
      count += 1 i range(len(list1)) range len(list1) len list1 for n in range(len(list1) - i - 1):
    if(list1[n] > list1[n + 1]):
      tmp = list1[n]
      list1[n] = list1[n + 1]
      list1[n + 1] = tmp
      count += 1 n range(len(list1) - i - 1) range len(list1) - i - 1 len(list1) - i len(list1) len list1 i 1 if(list1[n] > list1[n + 1]):
      tmp = list1[n]
      list1[n] = list1[n + 1]
      list1[n + 1] = tmp
      count += 1 list1[n] > list1[n + 1] list1[n] list1 n list1[n + 1] list1 n + 1 n 1 tmp = list1[n] tmp list1[n] list1 n list1[n] = list1[n + 1] list1[n] list1 n list1[n + 1] list1 n + 1 n 1 list1[n + 1] = tmp list1[n + 1] list1 n + 1 n 1 tmp count += 1 count 1 print(" ".join(str(x) for x in list1)) print " ".join(str(x) for x in list1) " ".join " " join str(x) str x print(count) print count list1 = [] [] list1 tmp = list1[n] list1[n] tmp count = 0 0 count list1  = list(map(int, input(). split())) list(map(int, input(). split())) list1 a = int(input()) int(input()) a count += 1 1 count
count = 0
list1 = []

a = int(input())
list1  = list(map(int, input(). split()))

for i in range(len(list1)):
  for n in range(len(list1) - i - 1):
    if(list1[n] > list1[n + 1]):
      tmp = list1[n]
      list1[n] = list1[n + 1]
      list1[n + 1] = tmp
      count += 1

print(" ".join(str(x) for x in list1))
print(count)