import collections

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

d = collections.defaultdict(int)
b = [0] * (n+1)
for i in range(n):
  b[i+1] = b[i] + a[i]

for bi in b:
  d[bi%m] += 1

print(sum([v*(v-1)//2 for v in d.values()]))
