N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

flag = True
c = 0
while flag:
    flag = False
    for j in reversed(range(1, N)):
        if  A[j - 1] > A[j]:
            A[j - 1],    A[j] = A[j], A[j - 1]
            c += 1
            flag = True
    
print(' '.join(map(str, A)))
print(c) N = int(input().rstrip()) N int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip A = list(map(int, input().rstrip().split())) A list(map(int, input().rstrip().split())) list map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split flag = True flag True c = 0 c 0 while flag:
    flag = False
    for j in reversed(range(1, N)):
        if  A[j - 1] > A[j]:
            A[j - 1],    A[j] = A[j], A[j - 1]
            c += 1
            flag = True
     flag flag = False flag False for j in reversed(range(1, N)):
        if  A[j - 1] > A[j]:
            A[j - 1],    A[j] = A[j], A[j - 1]
            c += 1
            flag = True
     j reversed(range(1, N)) reversed range(1, N) range 1 N if  A[j - 1] > A[j]:
            A[j - 1],    A[j] = A[j], A[j - 1]
            c += 1
            flag = True
     A[j - 1] > A[j] A[j - 1] A j - 1 j 1 A[j] A j A[j - 1],    A[j] = A[j], A[j - 1] A[j - 1] A j - 1 j 1 A[j] A j A[j] A j A[j - 1] A j - 1 j 1 c += 1 c 1 flag = True flag True print(' '.join(map(str, A))) print ' '.join(map(str, A)) ' '.join ' ' join map(str, A) map str A print(c) print c A = list(map(int, input().rstrip().split())) list(map(int, input().rstrip().split())) A c += 1 1 c flag = True True flag flag = False False flag c = 0 0 c N = int(input().rstrip()) int(input().rstrip()) N flag = True True flag
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

flag = True
c = 0
while flag:
    flag = False
    for j in reversed(range(1, N)):
        if  A[j - 1] > A[j]:
            A[j - 1],    A[j] = A[j], A[j - 1]
            c += 1
            flag = True
    
print(' '.join(map(str, A)))
print(c)