package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	count := 0
	isum := make([]int, n)
	isum[1] = a[0] % m
	for i := 1; i < n; i++ {
		isum[i] = (isum[i-1] + a[i]) % m
	}
	var now int
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if j == 0 {
				now = isum[i]
			} else {
				now = (now - a[j-1]) % m
			}
			if now == 0 {
				count++
			}
		}
	}
	fmt.Println(count)
}
