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