length = int(input())
targ = [int(n) for n in input().split(' ')]
swap = 0
for l in range(length):
    for m in range(l):
        if targ[l - m] < targ[l - m - 1]:
            disp = targ[l-m -1]
            targ[l-m-1] = targ[l-m]
            targ[l-m] = disp
            swap += 1
print(" ".join([str(n) for n in targ]))
print(swap) length = int(input()) length 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 targ = [int(n) for n in input().split(' ')] targ [int(n) for n in input().split(' ')] swap = 0 swap 0 for l in range(length):
    for m in range(l):
        if targ[l - m] < targ[l - m - 1]:
            disp = targ[l-m -1]
            targ[l-m-1] = targ[l-m]
            targ[l-m] = disp
            swap += 1 l range(length) range length for m in range(l):
        if targ[l - m] < targ[l - m - 1]:
            disp = targ[l-m -1]
            targ[l-m-1] = targ[l-m]
            targ[l-m] = disp
            swap += 1 m range(l) range l if targ[l - m] < targ[l - m - 1]:
            disp = targ[l-m -1]
            targ[l-m-1] = targ[l-m]
            targ[l-m] = disp
            swap += 1 targ[l - m] < targ[l - m - 1] targ[l - m] targ l - m l m targ[l - m - 1] targ l - m - 1 l - m l m 1 disp = targ[l-m -1] disp targ[l-m -1] targ l-m -1 l-m l m 1 targ[l-m-1] = targ[l-m] targ[l-m-1] targ l-m-1 l-m l m 1 targ[l-m] targ l-m l m targ[l-m] = disp targ[l-m] targ l-m l m disp swap += 1 swap 1 str(n) for n in targ for n in targ n targ for n in targ str(n) str n print(" ".join([str(n) for n in targ])) print " ".join([str(n) for n in targ]) " ".join " " join [str(n) for n in targ] print(swap) print swap length = int(input()) int(input()) length disp = targ[l-m -1] targ[l-m -1] disp targ = [int(n) for n in input().split(' ')] [int(n) for n in input().split(' ')] targ swap += 1 1 swap swap = 0 0 swap
length = int(input())
targ = [int(n) for n in input().split(' ')]
swap = 0
for l in range(length):
    for m in range(l):
        if targ[l - m] < targ[l - m - 1]:
            disp = targ[l-m -1]
            targ[l-m-1] = targ[l-m]
            targ[l-m] = disp
            swap += 1
print(" ".join([str(n) for n in targ]))
print(swap)