N = int(input())
A = [int(a) for a in input().split(" ")]
swop = 0
for i, a in enumerate(A):
    j = N - 1
    while j >= i + 1:
        if A[j] < A[j - 1]:
            tmp = A[j]
            A[j] = A[j - 1]
            A[j - 1] = tmp
            swop += 1
        j -= 1
print(" ".join([str(a) for a in A]))
print(swop) N = int(input()) N int(input()) int input() input int(a) for a in input().split(" ") for a in input().split(" ") a input().split(" ") ().split () input split " " for a in input().split(" ") int(a) int a A = [int(a) for a in input().split(" ")] A [int(a) for a in input().split(" ")] swop = 0 swop 0 for i, a in enumerate(A):
    j = N - 1
    while j >= i + 1:
        if A[j] < A[j - 1]:
            tmp = A[j]
            A[j] = A[j - 1]
            A[j - 1] = tmp
            swop += 1
        j -= 1 i a enumerate(A) enumerate A j = N - 1 j N - 1 N 1 while j >= i + 1:
        if A[j] < A[j - 1]:
            tmp = A[j]
            A[j] = A[j - 1]
            A[j - 1] = tmp
            swop += 1
        j -= 1 j >= i + 1 j i + 1 i 1 if A[j] < A[j - 1]:
            tmp = A[j]
            A[j] = A[j - 1]
            A[j - 1] = tmp
            swop += 1
         A[j] < A[j - 1] A[j] A j A[j - 1] A j - 1 j 1 tmp = A[j] tmp A[j] A j A[j] = A[j - 1] A[j] A j A[j - 1] A j - 1 j 1 A[j - 1] = tmp A[j - 1] A j - 1 j 1 tmp swop += 1 swop 1 j -= 1 j 1 str(a) for a in A for a in A a A for a in A str(a) str a print(" ".join([str(a) for a in A])) print " ".join([str(a) for a in A]) " ".join " " join [str(a) for a in A] print(swop) print swop A = [int(a) for a in input().split(" ")] [int(a) for a in input().split(" ")] A swop = 0 0 swop N = int(input()) int(input()) N swop += 1 1 swop tmp = A[j] A[j] tmp j = N - 1 N - 1 j j -= 1 1 j
N = int(input())
A = [int(a) for a in input().split(" ")]
swop = 0
for i, a in enumerate(A):
    j = N - 1
    while j >= i + 1:
        if A[j] < A[j - 1]:
            tmp = A[j]
            A[j] = A[j - 1]
            A[j - 1] = tmp
            swop += 1
        j -= 1
print(" ".join([str(a) for a in A]))
print(swop)