import numpy as np
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = np.array(a)
n = len(a)
count = 0
for l in range(n):
    for r in range(l, n):
        if sum(a[l:r + 1]) % m == 0:
            count += 1
print(count)
