import numpy as np

N, M = [int(i) for i in input().split()]
A = np.cumsum(np.array(input().split(), dtype=int))
ans = 0

for first in range(N):
    for last in range(first, N):
        if first == last:
            if A[first] % M == 0:
                ans += 1
        else:
            if (A[last] - A[first]) % M == 0:
                ans += 1

print(ans)