import sys
input=sys.stdin.readline

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    A=list(map(int,input().split()))
    dp=[[0 for i in range(N)] for j in range(N)]
    count = 0
    for i in range(N):
        dp[i][i]=A[i]
        dp[i][i]%=M
        if dp[i][i]==0:
            count+=1


    for l in range(N):
        for r in range(l,N-1):
            dp[l][r+1]=dp[l][r]+A[r+1]
            dp[l][r+1]%=M
            if dp[l][r+1]==0:
                count+=1

    print(count)


