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

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