# -*- coding: utf-8 -*-
import logging
import time
 
 
class Solver:
    def __init__(self):
        self.n, self.m = 0, 0
        self.a = []
 
    # 入力
    def input_value(self):
        # self.n = int(input())
        # self.A, self.B = map(int, input().split())
        # self.A = list(map(int, input().split()))
        # self.a, self.b, self.c = map(int, [input() for i in range(4)])
        # self.t = [None] * self.n
        self.n, self.m = map(int, input().split())
        self.a = list(map(int, input().split()))
 
    @staticmethod
    def run(m, a):
        count = 0
        for i in range(len(a)):
            a[i] = a[i] % m
            if a[i] % m == 0:
                count += 1
 
        for i in range(len(a)):
            b = [None] * (len(a) - i - 1)
            for j in range(len(b)):
                b[j] = sum(a[j:j + i + 2:1])
                if b[j] % m == 0:
                    count += 1
        # logging.debug(str(count))
        return count
 
    @staticmethod
    def test():
        start_time = time.time()
 
        assert Solver.run(2, [4, 1, 5]) == 3, 'Error.'
        assert Solver.run(17, [29, 7, 5, 7, 9, 51, 7, 13, 8, 55, 42, 9, 81]) == 6, 'Error.'
        assert Solver.run(400000000, [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, ]) == 25, 'Error.'
 
        elapsed_time = time.time() - start_time
        logging.debug('elapsed_time: {0}'.format(elapsed_time) + '[sec]')
 
 
if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
 
    solver = Solver()
 
    # Solver.test()
 
    solver.input_value()
    ans = solver.run(solver.m, solver.a)
    # print(str(ans))
    print(str(ans))