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

import numpy as np
cumsum = np.cumsum(a)
count = 0
for l in range(n):
    start_value = cumsum[l]
    for r in range(l, n):
        if cumsum[r] % m == 0:
            count += 1
    cumsum -= start_value
print(count)
