n ,m = map(int,input().split())
a = list(map(int,input().split()))
arr = [0] * n
arr[0] = a[0]
ans = 0

for i in range(1,n):
   arr[i] = arr[i - 1] + a[i]

for r in range(n):
    for l in range(0,r):
        if (arr[r] - arr[l]) % m ==0:
            ans += 1
    if arr[r] % m ==0:
        ans += 1

print(ans)