n = input()
a = map(int, raw_input().split())

c = 0
for i in range(n):
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1

print(" ".join(map(str, a)))
print(c) n = input() n input() input a = map(int, raw_input().split()) a map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split c = 0 c 0 for i in range(n):
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1 i range(n) range n for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1 j range(n - 1, i, -1) range n - 1 n 1 i -1 if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1 a[j] < a[j - 1] a[j] a j 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 c += 1 c 1 print(" ".join(map(str, a))) print " ".join(map(str, a)) " ".join " " join map(str, a) map str a print(c) print c c = 0 0 c n = input() input() n c += 1 1 c a = map(int, raw_input().split()) map(int, raw_input().split()) a
n = input()
a = map(int, raw_input().split())

c = 0
for i in range(n):
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            c += 1

print(" ".join(map(str, a)))
print(c)