n = int(input())
a = [int(x) for x in input().split()]

c = 0

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

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

c = 0

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

print(" ".join([str(x) for x in a]))
print(c)