# D - Candy Distribution

import numpy as np

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

C = A.cumsum()
C = np.insert(C,0,0)

ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if (C[j] - C[i]) % M == 0:
            ans += 1
            
print(ans)