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

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

cnt = 0
for i in range(n) :
    for j in range(n - 1, i, -1) :
        if s[j - 1] > s[j] :
            s[j - 1], s[j] = s[j], s[j - 1]
            cnt += 1     
print(" ".join(map(str, s)))
print(cnt)

