n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
m = a.min
if m*2 <= k
    puts -1
    exit
else
    puts m*n
    for i in 1..m
        for j in 1..n
            print j," "
        end
    end
end