n, m = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]

c_list = [0] * (n + 1)
for i in range(1, n + 1):
    c_list[i] = a_list[i - 1] + c_list[i - 1]

ans = 0
for i in range(1, n + 1):
    for j in range(i):
        if (c_list[i] - c_list[j]) % m == 0:
            ans += 1
print(ans)