fun main (args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toDouble() }
    val aList = readLine()!!.split(" ").map { it.toDouble() }

    val sumList = getSumList(aList)

    val count = sumList.count { it.rem(m) == 0.0 }

    println(count)
}

fun getSumList(aList: List<Double>): List<Double> {
    val sumList = ArrayList<Double>()
    for (l in 0 until aList.size) {
        for (r in l + 1..aList.size) {
            val sum = aList.subList(l, r).sum()
            sumList.add(sum)
        }
    }
    return sumList
}