n, m = map(int, input().split())
a_lis = list(map(int, input().split()))
a_sums = [0]
tmp_sum = 0
for i in range(n):
    tmp_sum += a_lis[i]
    a_sums.append(tmp_sum)
cnt = 0
for i in range(n + 1):
    for j in range(i + 1, n + 1):
        if (a_sums[j] - a_sums[i]) % m == 0:
            cnt += 1
print(cnt)