no = gets.to_i
arr = Array.new(no){
    gets.to_i
}



def insSort(arr, no, g)
    (g...no).each { |i|
        v = arr[i]
        j = i-g
        while j >= 0 && arr[j] > v
            arr[j+g] = arr[j]
            j=j-g
            $cnt += 1
        end

        arr[j+g] = v
    }
end

def shellSort(arr, no)
    g = 1
    while g < no/3
        g = 3*g + 1
    end

    while g > 0
        insSort(arr, no, g)
        $garr << g
        g = (g-1)/3
    end
end

$cnt=0
$m = 0
$garr = []

shellSort(arr, no)
$m = $garr.size

puts $m
puts $garr * ' '
puts $cnt
puts arr