import bisect

n,m = map(int, input().split())
a = [0]+list(map(int, input().split()))
n += 1
for i in range(1,n):
    a[i] += a[i-1]
    a[i] = a[i]%m
b = [0 for i in range(n)]
for i in range(n):
    b[i] = a[i]
b.sort()
b = list(set(b))
for i in range(n):
    a[i] = bisect.bisect_left(b,a[i])
dict = {}
flag = [False for i in range(max(a)+1)]
sum = 0
for i in a:
    if flag[i]:
        dict[i] += 1
    else:
        dict[i] = 1
        flag[i] = True
for i in dict.values():
    sum += i*(i-1)//2
print(sum)