# coding: utf-8
import collections
list = input().split()
N = int(list[0])
M = int(list[1])
a = input().split()
x = 0
hako = [0]
for i in a:
    hako.append(int(i))
B = []
b = 0
for i in hako:
    b += i
    B.append(b%M)
c = collections.Counter(B)
aaa =[]
for i in c:
    if c[i] >= 2:
        aaa.append(c[i])
def kaijo(n):
    if n == 0:
        return 1
    else:
        return n*kaijo(n-1)
def kumi(n):
    return int(kaijo(n)/(2*kaijo(n-2)))
for i in aaa:
    x += kumi(i)
print(x)