def insertionSort( nums, n, g ):
    cnt = 0
    for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
    return cnt
         
def shellSort( nums, n ):
    g = []
    v = 1
    while v <= n:
        g.append( v )
        v = 3*v+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( input( ) )
nums = [ int( input( ) ) for i in range( n ) ]
nums.append( 0 )
shellSort( nums, n )
nums.pop( )
for v in nums:
    print( v ) def insertionSort( nums, n, g ):
    cnt = 0
    for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
    return cnt
          insertionSort cnt = 0 cnt 0 for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
     i range( g, n ) range g n v = nums[i] v nums[i] nums i j = i - g j i - g i g while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
         j >= 0 and nums[j] > v j >= 0 j 0 nums[j] > v nums[j] nums j v 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 return cnt cnt nums nums n n g g def shellSort( nums, n ):
    g = []
    v = 1
    while v <= n:
        g.append( v )
        v = 3*v+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 [] v = 1 v 1 while v <= n:
        g.append( v )
        v = 3*v+1     
     v <= n v n g.append( v ) g.append g append v v = 3*v+1 v 3*v+1 3*v 3 v 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( input( ) ) n int( input( ) ) int input( ) input int( input( ) ) for i in range( n ) for i in range( n ) i range( n ) range n for i in range( n ) int( input( ) ) int input( ) input nums = [ int( input( ) ) for i in range( n ) ] nums [ int( input( ) ) for i in range( n ) ] nums.append( 0 ) nums.append nums append 0 shellSort( nums, n ) shellSort nums n nums.pop( ) nums.pop nums pop for v in nums:
    print( v ) v nums print( v ) print v nums = [ int( input( ) ) for i in range( n ) ] [ int( input( ) ) for i in range( n ) ] nums def insertionSort( nums, n, g ):
    cnt = 0
    for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
    return cnt
          def insertionSort( nums, n, g ):
    cnt = 0
    for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
    return cnt
          insertionSort def shellSort( nums, n ):
    g = []
    v = 1
    while v <= n:
        g.append( v )
        v = 3*v+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 = []
    v = 1
    while v <= n:
        g.append( v )
        v = 3*v+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 n = int( input( ) ) int( input( ) ) n
def insertionSort( nums, n, g ):
    cnt = 0
    for i in range( g, n ):
        v = nums[i]
        j = i - g
        while j >= 0 and nums[j] > v:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
         
        nums[ j+g ] = v
    return cnt
         
def shellSort( nums, n ):
    g = []
    v = 1
    while v <= n:
        g.append( v )
        v = 3*v+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( input( ) )
nums = [ int( input( ) ) for i in range( n ) ]
nums.append( 0 )
shellSort( nums, n )
nums.pop( )
for v in nums:
    print( v )