N = int(input())
*A, = map(int, input().split())
ans = 0
k = 0
while k < N - 1 :
    i = N - 1
    while i > k :
        if A[i] < A[i-1] :
            A[i], A[i-1] = A[i-1], A[i]
            ans = ans + 1
        i = i - 1    
    k = k + 1
print(*A)
print(ans) N = int(input()) N int(input()) int input() input *A, = map(int, input().split()) *A A map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 k = 0 k 0 while k < N - 1 :
    i = N - 1
    while i > k :
        if A[i] < A[i-1] :
            A[i], A[i-1] = A[i-1], A[i]
            ans = ans + 1
        i = i - 1    
    k = k + 1 k < N - 1 k N - 1 N 1 i = N - 1 i N - 1 N 1 while i > k :
        if A[i] < A[i-1] :
            A[i], A[i-1] = A[i-1], A[i]
            ans = ans + 1
        i = i - 1    
     i > k i k if A[i] < A[i-1] :
            A[i], A[i-1] = A[i-1], A[i]
            ans = ans + 1
         A[i] < A[i-1] A[i] A i A[i-1] A i-1 i 1 A[i], A[i-1] = A[i-1], A[i] A[i] A i A[i-1] A i-1 i 1 A[i-1] A i-1 i 1 A[i] A i ans = ans + 1 ans ans + 1 ans 1 i = i - 1 i i - 1 i 1 k = k + 1 k k + 1 k 1 print(*A) print *A A print(ans) print ans N = int(input()) int(input()) N k = 0 0 k i = N - 1 N - 1 i ans = 0 0 ans i = i - 1 i - 1 i ans = ans + 1 ans + 1 ans k = k + 1 k + 1 k
N = int(input())
*A, = map(int, input().split())
ans = 0
k = 0
while k < N - 1 :
    i = N - 1
    while i > k :
        if A[i] < A[i-1] :
            A[i], A[i-1] = A[i-1], A[i]
            ans = ans + 1
        i = i - 1    
    k = k + 1
print(*A)
print(ans)
