import scala.collection._

object Main{
	def main(A:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n,k = s.nextInt
		val a = Array.fill(n)(-s.nextInt)
		val r = new mutable.Queue[Int]
		var prev = -1
		for(_ <- 0 to k) {
			for(i <- (0 until n).sortBy(a) if i != prev) {
				a(i) += 1
				r += i + 1
				prev = i
			}
		}
		if(a forall (0 >=)) {
			println((n - 1) * (k + 1) + 1)
			println(r mkString " ")
		} else
			println(-1)
	}
}