import itertools

from math import factorial

from collections import Counter



ans = 0

N, L = list(map(int, input().split()))

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

y = itertools.accumulate(x)

y = [e % L for e in y]

#print(y)

#print(y)

so = set(y)

#print(so)

#print(so)

counter = Counter([0]+y)

#print(counter.values())

#print

for i in list(counter.values()):

    #print(ans)

    if i>1:ans+=factorial(i) // 2 // factorial(i-2)

print(ans)
import itertools

from math import factorial

from collections import Counter



ans = 0

N, L = list(map(int, input().split()))

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

y = itertools.accumulate(x)

y = [e % L for e in y]

#print(y)

#print(y)

so = set(y)

#print(so)

#print(so)

counter = Counter([0]+y)

#print(counter.values())

#print

for i in list(counter.values()):

    #print(ans)

    ans+=i * (i - 1) // 2

print(ans)
import itertools
from math import factorial
from collections import Counter

ans = 0
N, L = list(map(int, input().split()))
x = list(map(int, input().split()))
y = itertools.accumulate(x)
y = [e % L for e in y]
# print(y)
# print(y)
so = set(y)
# print(so)
# print(so)
counter = Counter([0] + y)
# print(counter.values())
# print
for i in list(counter.values()):
    # print(ans)
    if i > 1:
        ans += factorial(i) // 2 // factorial(i - 2)
print(ans)

import itertools
from math import factorial
from collections import Counter

ans = 0
N, L = list(map(int, input().split()))
x = list(map(int, input().split()))
y = itertools.accumulate(x)
y = [e % L for e in y]
# print(y)
# print(y)
so = set(y)
# print(so)
# print(so)
counter = Counter([0] + y)
# print(counter.values())
# print
for i in list(counter.values()):
    # print(ans)
    ans += i * (i - 1) // 2
print(ans)

-    if i > 1: -        ans += factorial(i) // 2 // factorial(i - 2) +    ans += i * (i - 1) // 2