import math
def f(x):return math.factorial(x)
def g(x):return f(x)//(f(x-2)*f(2))if x>1else 0
n,m=map(int,input().split())
b=0
c={}
for a in input().split():
  b+=int(a)
  c[b%m]=c.get(b%m,0)+1
print(sum(map(lambda x:g(x),c.values()))+c.get(0,0))