package main

import "fmt"

func main() {
	var i, t int
	var N, M int
	var a int

	fmt.Scan(&N)
	fmt.Scan(&M)

	A := make([]int, N)
	for i = 0; i < N; i++ {
		fmt.Scan(&a)
		A[i] = a % M
	}

	var result int64

	for i = 0; i < N; i++ {
		t = 0
		for j := i; j < N; j++ {
			t += A[j]
			if t >= M {
				t -= M
			}
			if t == 0 {
				result++
			}
		}
	}

	fmt.Println(result)
}
