N,M = list(map(int,input().split()))
A = input().split()

import numpy as np
A = np.array(A,dtype='int64')

def count_A(N,M,A):
  count=0
  for i in range(N+1):
    for t in range(N+1):
      count+=1 if i<t and np.sum(A[i:t])%M==0 else 0
  return print(count)
count_A(N,M,A)