# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect
import numpy as np

def ln():
    return map(int, input().split())

N,M = ln()
AA = list(ln())
A = np.array(AA)
A = A%M

SUM = np.zeros(N+1,dtype = int)
for i in range(N):
    SUM[i+1] = SUM[i] + A[i]
SUM %= M
ans = 0

for i in range(N):
    ans += np.sum(SUM[i+1:] == SUM[i])

print(ans)
