n = int(input())
k = [int(i) for i in input().split()]
M = 0
for i in range(n-1):
    for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass

print(' '.join(map(str, k)))
print(M) 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 k = [int(i) for i in input().split()] k [int(i) for i in input().split()] M = 0 M 0 for i in range(n-1):
    for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass i range(n-1) range n-1 n 1 for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass l range(n-i-1) range n-i-1 n-i n i 1 if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass k[n-2-l] > k[n-1-l] k[n-2-l] k n-2-l n-2 n 2 l k[n-1-l] k n-1-l n-1 n 1 l v = k[n-1-l] v k[n-1-l] k n-1-l n-1 n 1 l k[n - 1 - l]=k[n-2-l] k[n - 1 - l] k n - 1 - l n - 1 n 1 l k[n-2-l] k n-2-l n-2 n 2 l k[n - 2 - l]=v k[n - 2 - l] k n - 2 - l n - 2 n 2 l v M+=1 M 1 print(' '.join(map(str, k))) print ' '.join(map(str, k)) ' '.join ' ' join map(str, k) map str k print(M) print M M = 0 0 M n = int(input()) int(input()) n M+=1 1 M v = k[n-1-l] k[n-1-l] v k = [int(i) for i in input().split()] [int(i) for i in input().split()] k
n = int(input())
k = [int(i) for i in input().split()]
M = 0
for i in range(n-1):
    for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass

print(' '.join(map(str, k)))
print(M)