n, m = map(int, input().split())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
ans = 0
for i in range(n):
    ans += sum(list(map(lambda x: not (x - a_t[i]) % m, a_t[i + 1:])))
print(ans)