N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
queue1 = [A]
while queue1:
    array1 = queue1.pop(0)
    flag1 = False
    for i in range(len(array1), 0, -1):
        for j in range(len(array1)-i+1):
            if sum(array1[j:j+i]) % M == 0:
                flag = True
                if j-2 > 0:
                    queue1.append(array1[:j-2])
                if j+i+1 < len(array1):
                    queue1.append(array1[j+i+1:])
                queue2 = [array1[j:j+1]]
                counter = 1
                while queue2:
                    flag2 = False
                    array2 = queue2.pop(0)
                    for k in range(len(array2)-1, 0, -1):
                        for l in range(len(array2)-k+1):
                            if sum(array2[l:l+k]) % M == 0:
                                flag2 = True
                                counter += 1
                                queue2.append(array2[l:l+k])
                                break

                        if flag2:
                            break

                ans += (counter * (counter + 1)) // 2
                break

        if flag1:
            break

print(ans)
