# -*- coding: utf-8 -*-
"""
Insertion Sort - CodeAbbey
Created on Sun Mar 1 18:49:30 2020
@author: Diego Sanchez
"""
def insertionSort(nlist):
for index in range(1,len(nlist)):
c = 0
currentvalue = nlist[index]
position = index
while position>0 and nlist[position-1]>currentvalue:
nlist[position]=nlist[position-1]
c += 1
position = position-1
nlist[position]=currentvalue
print(c)
#nlist = [14,46,43,27,57,41,45,21,70]
nlist = []
n = int(input())
for i in range(n):
l = int(input())
[Link](l)
insertionSort(nlist)
print(nlist)