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