from collections import Counter

n,m = list(map(int,input().split()))

A = list(map(int,input().split()))

B = [0]

for a in A:

    B.append((B[-1]+a)%m)

D = Counter(B)

res = 0

for v in list(D.values()):

    res += v*(v-1)//2

print(res)

import collections,itertools

n,m = list(map(int,input().split()))

s = [0]

s.extend(itertools.accumulate(list(map(int,input().split()))))

s = collections.Counter(a%m for a in s)

print((sum(v*(v-1)//2 for v in list(s.values()))))

from collections import Counter

n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0]
for a in A:
    B.append((B[-1] + a) % m)
D = Counter(B)
res = 0
for v in list(D.values()):
    res += v * (v - 1) // 2
print(res)

import collections, itertools

n, m = list(map(int, input().split()))
s = [0]
s.extend(itertools.accumulate(list(map(int, input().split()))))
s = collections.Counter(a % m for a in s)
print((sum(v * (v - 1) // 2 for v in list(s.values()))))

-from collections import Counter +import collections, itertools -A = list(map(int, input().split())) -B = [0] -for a in A: -    B.append((B[-1] + a) % m) -D = Counter(B) -res = 0 -for v in list(D.values()): -    res += v * (v - 1) // 2 -print(res) +s = [0] +s.extend(itertools.accumulate(list(map(int, input().split())))) +s = collections.Counter(a % m for a in s) +print((sum(v * (v - 1) // 2 for v in list(s.values()))))