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)

c = Counter(B)

ans = 0

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

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

print(ans)

from collections import Counter

def main():

    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)

    c = Counter(B)

    ans = 0

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

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

    print(ans)



if __name__ == '__main__':

    main()
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)
c = Counter(B)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

from collections import Counter


def main():
    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)
    c = Counter(B)
    ans = 0
    for v in list(c.values()):
        ans += v * (v - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

-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) -c = Counter(B) -ans = 0 -for v in list(c.values()): -    ans += v * (v - 1) // 2 -print(ans) + +def main(): +    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) +    c = Counter(B) +    ans = 0 +    for v in list(c.values()): +        ans += v * (v - 1) // 2 +    print(ans) + + +if __name__ == "__main__": +    main()