import numpy as np
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a = [aa%m for aa in a]


ans = []
for k in range(len(a)):
    ans.append(len(np.where(np.cumsum(a[k:])%m == 0)[0]))
print(np.sum(ans))