N,M = (int(x) for x in input().split())
A_arr = [int(x) for x in input().split()]

mM_map = {0:1}
tmp = 0
for A in A_arr:
    tmp = (tmp+A)%M
    mM_map.setdefault(tmp, 0)
    mM_map[tmp] += 1

ans = 0
for v in mM_map.values():
    ans += v*(v-1)//2

print(ans)


