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

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



s = [0]#s[i]はaからi個取った累積和

for i in range(len(a)):

    s.append((s[i] + a[i]) % m)



ans = 0

d = dict()

for i in range(len(s)):

    t = d.get(s[i], 0)

    ans += t

    d[s[i]] = t + 1

print(ans)
def iin(): return int(eval(input()))

def nl(): return list(map(int, input().split()))



n, m = nl()

a = nl()



csum = [0]

for x in a:

    csum.append((csum[-1] + x) % m)



d = dict()

ans = 0

for x in csum:

    t = d.get(x, 0)

    ans += t

    d[x] = t + 1

    

print(ans)
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
s = [0]  # s[i]はaからi個取った累積和
for i in range(len(a)):
    s.append((s[i] + a[i]) % m)
ans = 0
d = dict()
for i in range(len(s)):
    t = d.get(s[i], 0)
    ans += t
    d[s[i]] = t + 1
print(ans)

def iin():
    return int(eval(input()))


def nl():
    return list(map(int, input().split()))


n, m = nl()
a = nl()
csum = [0]
for x in a:
    csum.append((csum[-1] + x) % m)
d = dict()
ans = 0
for x in csum:
    t = d.get(x, 0)
    ans += t
    d[x] = t + 1
print(ans)

-n, m = list(map(int, input().split())) -a = list(map(int, input().split())) -s = [0]  # s[i]はaからi個取った累積和 -for i in range(len(a)): -    s.append((s[i] + a[i]) % m) +def iin(): +    return int(eval(input())) + + +def nl(): +    return list(map(int, input().split())) + + +n, m = nl() +a = nl() +csum = [0] +for x in a: +    csum.append((csum[-1] + x) % m) +d = dict() -d = dict() -for i in range(len(s)): -    t = d.get(s[i], 0) +for x in csum: +    t = d.get(x, 0) -    d[s[i]] = t + 1 +    d[x] = t + 1