package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	csum := make([]int, n+1)
	csum[0] = 0
	for i, a := range as {
		csum[i+1] = (csum[i] + a) % m
	}

	var result int64
	for l := 0; l < n; l++ {
		for r := l; r < n; r++ {
			if (csum[r+1]-csum[l])%m == 0 {
				result++
			}
		}
	}
	fmt.Println(result)
}
