#! /usr/bin/env python3

n, m = map(int, input().split())
a = [int(i) for i in input().split()]

acc = [0 for _ in range(n + 1)]
res = 0

for i in range(n):
    acc[i + 1] = (acc[i] + a[i]) % m
    for j in range(i + 1):
        if (m + acc[i + 1] - acc[j]) % m == 0:
            res += 1

print(res)
