def main():
    t = input().split(" ")
    N, M = int(t[0]), int(t[1])

    t = input().split(" ")
    a = [int(i)%M for i in t]
    ans = 0
    s = [a[0]]
    if a[0] == 0:
        ans += 1
    for i in range(1,N):
        for j in range(i):
            s[j] = (s[j] + a[i]) % M
            if s[j] == 0:
                ans += 1
        s.append(a[i])
        if a[i] == 0:
            ans += 1
    print(ans)
main()
