from collections import Counter

n, m = map(int, input().split())
a = list(map(int, input().split()))
SUM = [0]

for i in a:
    SUM.append((SUM[-1]+i)%m)

#SUM.pop(0)
c = Counter(SUM)
C = c.most_common()
C_srt = sorted(C)
ans = 0

for i in C:
    if i[1] > 1:
        if i[0] == 0:
            ans += i[1]*(i[1]+1)//2
        else:
            ans += i[1]*(i[1]-1)//2
    else:
        break
print(ans)
