# -*- 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)

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

ans = 0
dic = dict()
for i in range(N):
    dic[SUM[i]] = 1
for i in range(N+1):
    ans += dic[SUM[i]] -1
    dic[SUM[i]] += 1

print(ans)
