import java.util.* fun main(arr:Array) { val (amebaCount, move, totalTime) = readLine()!!.split(" ").map { it.toInt() } val amebaList = readLine()!!.split(" ").map { Ameba(it.toLong() - move.toLong() * totalTime, it.toLong() + move.toLong() * totalTime) }.sortedBy { it.from }.toMutableList() val minPos = amebaList.minBy { it.from }!!.from val amebaMap = mutableMapOf>() amebaList.map { (it.from - minPos) % move }.distinct().forEach { amebaMap[it] = mutableListOf() } var ans = 0.toLong() amebaMap.forEach { val key = it.key val list = amebaList.filter { (it.from - minPos) % move == key }.sortedBy { it.from }.toMutableList() for(i in list.lastIndex downTo 1) { if(list[i-1].to >= list[i].from) { list[i-1] = Ameba(list[i-1].from, list[i].to) list.removeAt(i) } } ans += list.map { (it.to - it.from) / move + 1 }.sum() } println(ans) } class Ameba(var from:Long, var to:Long)