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

#m, a = 17, [29, 7, 5, 7, 9, 51, 7, 13, 8, 55, 42, 9, 81]

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