import collections

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 1
N = 10 ** 5 + 1  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
n, m = map(int, input().split())
A = list(map(int, input().split()))
ans_list = [0] * (n + 1)
for i in range(1, n + 1):
  A[i - 1] %= m
  ans_list[i] = (ans_list[i - 1] + A[i - 1]) % m
ans_list.pop(ans_list[0])
ans_list = dict(collections.Counter(ans_list))
  
#print(A)
#print(ans_list)
count = ans_list[0]
#print(count)
for v in ans_list.values():
  #print(v)
  if v != 1:
    count +=  v * (v - 1) / 2
    
print(int(count))   
    
    
