# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c1 = [0]
c2 = [0]
bb=0
c2[0]=1
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    if bb == 0:
        c2[0] += 1
    else:
        if bb in c1:
            c2[c1.index(bb)] += 1
        else:
            c1.append(bb)
            c2.append(1)
    
    
answer = 0
#print(c1)
#print(c2)
for i in range(0,len(c2)):
    cc = c2[i]
    if cc > 1:
        answer +=  (cc * (cc-1) // 2 )

print(answer)

