package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, m int

	fmt.Fscan(r, &n, &m)
	curR := 0
	a := make([]int, n)
	rs := make([]int, m)
	rs[0] = 1
	ans := 0
	for i := 0; i < n; i++ {
		var ai int
		fmt.Fscan(r, &ai)
		a[i] = ai % m
		curR += ai % m
		ans += rs[curR%m]
		rs[curR%m]++
	}
	fmt.Fprintln(w, ans)
}