package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d%d", &N, &M)
	sA := make([]int, N+1)
	q := make([]int, M)
	q[0]++
	for i := 0; i < N; i++ {
		var A int
		fmt.Scanf("%d", &A)
		sA[i+1] = (sA[i] + A) % M
		q[sA[i+1]]++
	}
	ans := 0
	/*
		for i := 0; i <= N; i++ {
			for j := 0; j < i; j++ {
				if sA[i]-sA[j] == 0 {
					ans++
				}
			}
		}
	*/
	for i := 0; i <= N; i++ {
		q[sA[i]]--
		//fmt.Printf("%d %d\n", sA[i], q[sA[i]])
		ans += q[sA[i]]
	}
	fmt.Printf("%d\n", ans)
}
