# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [0]*(n)
c = [0]*(m)
bb=0
c[0]=1
for i in range(0,n) :
    bb = ( bb+a[i] ) % m
    c[bb] += 1
    
    
answer = 0
print(c)
for i in range(0,m):
    if c[i] > 1:
        answer +=  (c[i] * (c[i]-1) // 2 )

print(answer)

