package main

import (
	"fmt"
)

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