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=list(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([g(x) for x in list(c.values())])+c.get(0,0)))
n,m,*c=list(map(int,open(0).read().split()))

d={0:1}

r=s=0

for i in c:s+=i;x=d.get(s%m,0);r+=x;d[s%m]=x+1

print(r)
import math


def f(x):
    return math.factorial(x)


def g(x):
    return f(x) // (f(x - 2) * f(2)) if x > 1 else 0


n, m = list(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([g(x) for x in list(c.values())]) + c.get(0, 0)))

n, m, *c = list(map(int, open(0).read().split()))
d = {0: 1}
r = s = 0
for i in c:
    s += i
    x = d.get(s % m, 0)
    r += x
    d[s % m] = x + 1
print(r)

-import math - - -def f(x): -    return math.factorial(x) - - -def g(x): -    return f(x) // (f(x - 2) * f(2)) if x > 1 else 0 - - -n, m = list(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([g(x) for x in list(c.values())]) + c.get(0, 0))) +n, m, *c = list(map(int, open(0).read().split())) +d = {0: 1} +r = s = 0 +for i in c: +    s += i +    x = d.get(s % m, 0) +    r += x +    d[s % m] = x + 1 +print(r)