from collections import Counter as C
from itertools import accumulate as a
def inp():return map(int,input().split())
n,m = inp()
print(sum([v*(v-1)//2+(0 if k else v)for k,v in C(map(lambda x:x%m,a(inp()))).items()]))