n = int(input())
a = list(map(str, input().split()))
a_swap = 0

flag = True
while flag:
    flag = False
    for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1

print(" ".join(a))
print(a_swap) n = int(input()) n int(input()) int input() input a = list(map(str, input().split())) a list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split a_swap = 0 a_swap 0 flag = True flag True while flag:
    flag = False
    for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1 flag flag = False flag False for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1 j range(n-1,0,-1) range n-1 n 1 0 -1 if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1 int(a[j]) < int(a[j-1]) int(a[j]) int a[j] a j int(a[j-1]) int a[j-1] a j-1 j 1 a[j],a[j-1] = a[j-1],a[j] a[j] a j a[j-1] a j-1 j 1 a[j-1] a j-1 j 1 a[j] a j flag = True flag True a_swap += 1 a_swap 1 print(" ".join(a)) print " ".join(a) " ".join " " join a print(a_swap) print a_swap a = list(map(str, input().split())) list(map(str, input().split())) a flag = True True flag a_swap = 0 0 a_swap a_swap += 1 1 a_swap flag = True True flag n = int(input()) int(input()) n flag = False False flag
n = int(input())
a = list(map(str, input().split()))
a_swap = 0

flag = True
while flag:
    flag = False
    for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1

print(" ".join(a))
print(a_swap)