import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, M = li_input()
    A = li_input()

    ans = 0

    cumsum = [0]
    c_sum = 0
    for a in A:
        c_sum += a
        cumsum.append(c_sum)

    for r in range(1, len(cumsum)):
        for l in range(r):
            if (cumsum[r] - cumsum[l]) % M == 0:
                ans += 1

    print(ans)


main()
