import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())

a = list( map(int, input().split()))

ans=0
right=n-1
array_sum = 0
for left in range(n):
    array_sum = sum(a[left:])
    while right>=left and array_sum >m:
        if array_sum%m == 0: ans+=1
        array_sum -= a[right]
        right-=1
    right=n-1

print(ans)
