N = int(input())
a = list(map(int, input().split()))
flag = 1
z = 0
while flag:
  flag = 0
  for j in range(N - 1, 0, -1):
    if a[j] < a[j - 1]:
      a[j - 1], a[j] = a[j], a[j - 1]
      flag = 1
      z += 1
print(*a)
print(z) 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 flag = 1 flag 1 z = 0 z 0 while flag:
  flag = 0
  for j in range(N - 1, 0, -1):
    if a[j] < a[j - 1]:
      a[j - 1], a[j] = a[j], a[j - 1]
      flag = 1
      z += 1 flag flag = 0 flag 0 for j in range(N - 1, 0, -1):
    if a[j] < a[j - 1]:
      a[j - 1], a[j] = a[j], a[j - 1]
      flag = 1
      z += 1 j range(N - 1, 0, -1) range N - 1 N 1 0 -1 if a[j] < a[j - 1]:
      a[j - 1], a[j] = a[j], a[j - 1]
      flag = 1
      z += 1 a[j] < a[j - 1] a[j] a j a[j - 1] a j - 1 j 1 a[j - 1], a[j] = a[j], a[j - 1] a[j - 1] a j - 1 j 1 a[j] a j a[j] a j a[j - 1] a j - 1 j 1 flag = 1 flag 1 z += 1 z 1 print(*a) print *a a print(z) print z z = 0 0 z N = int(input()) int(input()) N z += 1 1 z flag = 1 1 flag a = list(map(int, input().split())) list(map(int, input().split())) a flag = 1 1 flag flag = 0 0 flag
N = int(input())
a = list(map(int, input().split()))
flag = 1
z = 0
while flag:
  flag = 0
  for j in range(N - 1, 0, -1):
    if a[j] < a[j - 1]:
      a[j - 1], a[j] = a[j], a[j - 1]
      flag = 1
      z += 1
print(*a)
print(z)