data_num = int(input())
data = [int(n) for n in input().split(' ')]
data_len = len(data)

flag = True
i = 0
changed = 0

while flag:
    flag = False
    for j in range(data_len-1, i, -1):
        if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            changed += 1
            flag = True
    i += 1
print(' '.join(str(i) for i in data))

print(changed) data_num = int(input()) data_num int(input()) int input() input int(n) for n in input().split(' ') for n in input().split(' ') n input().split(' ') ().split () input split ' ' for n in input().split(' ') int(n) int n data = [int(n) for n in input().split(' ')] data [int(n) for n in input().split(' ')] data_len = len(data) data_len len(data) len data flag = True flag True i = 0 i 0 changed = 0 changed 0 while flag:
    flag = False
    for j in range(data_len-1, i, -1):
        if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            changed += 1
            flag = True
    i += 1 flag flag = False flag False for j in range(data_len-1, i, -1):
        if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            changed += 1
            flag = True
     j range(data_len-1, i, -1) range data_len-1 data_len 1 i -1 if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            changed += 1
            flag = True
     data[j] < data[j-1] data[j] data j data[j-1] data j-1 j 1 data[j], data[j-1] = data[j-1], data[j] data[j] data j data[j-1] data j-1 j 1 data[j-1] data j-1 j 1 data[j] data j changed += 1 changed 1 flag = True flag True i += 1 i 1 print(' '.join(str(i) for i in data)) print ' '.join(str(i) for i in data) ' '.join ' ' join str(i) str i print(changed) print changed changed = 0 0 changed data = [int(n) for n in input().split(' ')] [int(n) for n in input().split(' ')] data i = 0 0 i data_len = len(data) len(data) data_len flag = True True flag changed += 1 1 changed i += 1 1 i data_num = int(input()) int(input()) data_num flag = True True flag flag = False False flag
data_num = int(input())
data = [int(n) for n in input().split(' ')]
data_len = len(data)

flag = True
i = 0
changed = 0

while flag:
    flag = False
    for j in range(data_len-1, i, -1):
        if data[j] < data[j-1]:
            data[j], data[j-1] = data[j-1], data[j]
            changed += 1
            flag = True
    i += 1
print(' '.join(str(i) for i in data))

print(changed)