from itertools import combinations
n, m = map(int, input().split())
l = list(map(int, input().split()))
sum = [0]*(n+1)
ans = 0
for i in range(1, n+1):
  sum[i] = sum[i-1] + l[i-1] 

combos = list(combinations(sum, 2))

for combo in combos:
  l, r = combo
  if l % m == r % m:
    ans += 1

print(ans)
