import numpy as np
import math

N, M = map(int, input().split())

A = list(map(int, input().split()))

# 1 <= N <= 10^5
# 2 <= M <= 10^9
# 1 <= A <= 10^9

dp = np.zeros(N+1, dtype=int)

dp[N] = 0

total = 0
mods = dict()
mods[0] = 1

for i in reversed(range(N)):
    newdic = dict()
    for mod, count in mods.items():
        newm = (A[i] + mod) % M
        if newm == 0:
            total += count
        newdic[newm] = count

    if 0 in newdic.keys():
        newdic[0] += 1
    else:
        newdic[0] = 1
    mods = newdic
        # print(mods)
    
print(total)
