import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
A0 = rl()
A = np.array(A0)
A_cum = A.cumsum()
A_cum %= M
answer = 0

for i in range(N):
    answer += (A_cum[i:] == 0).sum()
    A_cum -= A0[i]

print(answer)
#13