def main():
    N, M = map(int, input().split())
    A = [_ for _ in map(int, input().split())]
    d = {}
    result = 0
    for i in range(0, N):
        for j in range(i+1, N+1):
            if j not in d:
                if (j-1) not in d:
                    d[j] = sum(A[:j])
                else:
                    d[j] = d[j-1] + A[j-1]
            if i not in d:
                d[i] = sum(A[:i])
            if (d[j] - d[i]) % M == 0:
                result += 1
    print(result)


if __name__ == "__main__":
    main()
