import sys

def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		
def shellSort( nums, n ):
	g = []
	val = 1
	while val <= n:
		g.append( val )
		val = 3*val+1
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
    
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
	nums.append( int( sys.stdin.readline( ) ) )

shellSort( nums, n )
print( "\n".join( map( str, nums ) ) ) import sys sys def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		 insertionSort cnt = 0 cnt 0 i = g i g while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	 i < n i n v = nums[i] v nums[i] nums i j = i - g j i - g i g while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		 0 <= j and v < nums[j] 0 <= j 0 j v < nums[j] v nums[j] nums j nums[ j+g ] = nums[j] nums[ j+g ] nums j+g j g nums[j] nums j j -= g j g cnt += 1 cnt 1 nums[ j+g ] = v nums[ j+g ] nums j+g j g v i += 1 i 1 return cnt cnt nums nums n n g g def shellSort( nums, n ):
	g = []
	val = 1
	while val <= n:
		g.append( val )
		val = 3*val+1
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
     shellSort g = [] g [] val = 1 val 1 while val <= n:
		g.append( val )
		val = 3*val+1
	
	 val <= n val n g.append( val ) g.append g append val val = 3*val+1 val 3*val+1 3*val 3 val 1 g.reverse( ) g.reverse g reverse m = len( g ) m len( g ) len g print( m ) print m print( " ".join( map( str, g ) ) ) print " ".join( map( str, g ) ) " ".join " " join map( str, g ) map str g cnt = 0 cnt 0 for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	 i range( m ) range m cnt += insertionSort( nums, n, g[i] ) cnt insertionSort( nums, n, g[i] ) insertionSort nums n g[i] g i print( cnt ) print cnt nums nums n n n = int( sys.stdin.readline( ) ) n int( sys.stdin.readline( ) ) int sys.stdin.readline( ) sys.stdin.readline sys.stdin sys stdin readline nums = [] nums [] for i in range( n ):
	nums.append( int( sys.stdin.readline( ) ) ) i range( n ) range n nums.append( int( sys.stdin.readline( ) ) ) nums.append nums append int( sys.stdin.readline( ) ) int sys.stdin.readline( ) sys.stdin.readline sys.stdin sys stdin readline shellSort( nums, n ) shellSort nums n print( "\n".join( map( str, nums ) ) ) print "\n".join( map( str, nums ) ) "\n".join "\n" join map( str, nums ) map str nums def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		 def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		 insertionSort n = int( sys.stdin.readline( ) ) int( sys.stdin.readline( ) ) n nums = [] [] nums def shellSort( nums, n ):
	g = []
	val = 1
	while val <= n:
		g.append( val )
		val = 3*val+1
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
     def shellSort( nums, n ):
	g = []
	val = 1
	while val <= n:
		g.append( val )
		val = 3*val+1
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
     shellSort
import sys

def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt
		
def shellSort( nums, n ):
	g = []
	val = 1
	while val <= n:
		g.append( val )
		val = 3*val+1
	
	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	cnt = 0
	for i in range( m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )
    
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
	nums.append( int( sys.stdin.readline( ) ) )

shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )