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