n = int(input())
A = list(map(int, input().split()))
nums = [n - i for i in range(1, n)]
flag = 1
exchange = 0

while flag == 1:
    flag = 0
    for j in nums:
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            exchange += 1
            flag = 1
        else:
            pass
        
print(*A)
print(exchange) n = int(input()) n int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split n - i for i in range(1, n) for i in range(1, n) i range(1, n) range 1 n for i in range(1, n) n - i n i nums = [n - i for i in range(1, n)] nums [n - i for i in range(1, n)] flag = 1 flag 1 exchange = 0 exchange 0 while flag == 1:
    flag = 0
    for j in nums:
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            exchange += 1
            flag = 1
        else:
            pass
         flag == 1 flag 1 flag = 0 flag 0 for j in nums:
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            exchange += 1
            flag = 1
        else:
            pass
         j nums if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            exchange += 1
            flag = 1
        else:
            pass
         A[j] < A[j - 1] A[j] A j A[j - 1] A j - 1 j 1 A[j], A[j - 1] = A[j - 1], A[j] A[j] A j A[j - 1] A j - 1 j 1 A[j - 1] A j - 1 j 1 A[j] A j exchange += 1 exchange 1 flag = 1 flag 1 print(*A) print *A A print(exchange) print exchange flag = 0 0 flag exchange += 1 1 exchange flag = 1 1 flag n = int(input()) int(input()) n nums = [n - i for i in range(1, n)] [n - i for i in range(1, n)] nums flag = 1 1 flag A = list(map(int, input().split())) list(map(int, input().split())) A exchange = 0 0 exchange
n = int(input())
A = list(map(int, input().split()))
nums = [n - i for i in range(1, n)]
flag = 1
exchange = 0

while flag == 1:
    flag = 0
    for j in nums:
        if A[j] < A[j - 1]:
            A[j], A[j - 1] = A[j - 1], A[j]
            exchange += 1
            flag = 1
        else:
            pass
        
print(*A)
print(exchange)
