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