n, m = map(int, input().split())
a = list(map(int, input().split()))
t = [0]
v = 0
if n * n / 2 > m:
    mod = [0] * m
    for i in range(len(a)):
        v += a[i]
        mod[v%m] += 1
    ans = mod[0]
    for i in range(m):
        ans += mod[i] * (mod[i]-1) / 2
    print(int(ans))
else:
    ans = 0
    for i in range(len(a)):
        v += a[i]
        t.append(v)
    for i in range(len(t)-1):
        for j in range(i+1, len(t)):
            if (t[j]-t[i]) % m == 0:
                ans += 1
    print(ans)