n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(a[0])
for idx in range(1,len(a)):
  s.append(s[idx-1] + a[idx])

cnt = 0
for l in range(n):
  for r in range(l, n):
    if (s[r] - s[l-1]) % m == 0:
      cnt += 1
print(cnt)
