package main

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

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

	var n, m int64

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