n = int(input())
a = [int(i) for i in input().split()]

num = 0

is_swapped = True
while is_swapped:
    is_swapped = False
    for i in range(n-1, 0, -1):
        if a[i] < a[i-1]:
            tmp = a[i]
            a[i] = a[i-1]
            a[i-1] = tmp
            is_swapped = True
            num += 1

print(' '.join([str(i) for i in a]))
print(num) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a = [int(i) for i in input().split()] a [int(i) for i in input().split()] num = 0 num 0 is_swapped = True is_swapped True while is_swapped:
    is_swapped = False
    for i in range(n-1, 0, -1):
        if a[i] < a[i-1]:
            tmp = a[i]
            a[i] = a[i-1]
            a[i-1] = tmp
            is_swapped = True
            num += 1 is_swapped is_swapped = False is_swapped False for i in range(n-1, 0, -1):
        if a[i] < a[i-1]:
            tmp = a[i]
            a[i] = a[i-1]
            a[i-1] = tmp
            is_swapped = True
            num += 1 i range(n-1, 0, -1) range n-1 n 1 0 -1 if a[i] < a[i-1]:
            tmp = a[i]
            a[i] = a[i-1]
            a[i-1] = tmp
            is_swapped = True
            num += 1 a[i] < a[i-1] a[i] a i a[i-1] a i-1 i 1 tmp = a[i] tmp a[i] a i a[i] = a[i-1] a[i] a i a[i-1] a i-1 i 1 a[i-1] = tmp a[i-1] a i-1 i 1 tmp is_swapped = True is_swapped True num += 1 num 1 str(i) for i in a for i in a i a for i in a str(i) str i print(' '.join([str(i) for i in a])) print ' '.join([str(i) for i in a]) ' '.join ' ' join [str(i) for i in a] print(num) print num a = [int(i) for i in input().split()] [int(i) for i in input().split()] a is_swapped = True True is_swapped num = 0 0 num is_swapped = True True is_swapped tmp = a[i] a[i] tmp n = int(input()) int(input()) n is_swapped = False False is_swapped num += 1 1 num
n = int(input())
a = [int(i) for i in input().split()]

num = 0

is_swapped = True
while is_swapped:
    is_swapped = False
    for i in range(n-1, 0, -1):
        if a[i] < a[i-1]:
            tmp = a[i]
            a[i] = a[i-1]
            a[i-1] = tmp
            is_swapped = True
            num += 1

print(' '.join([str(i) for i in a]))
print(num)
