import math
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:math.factorial(x)//(math.factorial(x-2)*math.factorial(2))if x>1else 0,c.values()))+c.get(0,0))