def f(As, M):
    prev = None
    c = 0

    for i, A in enumerate(As):
        A %= M
        if i == 0:
            prev = {A: 1}
            if A == 0:
                c += 1
            continue

        ccc = {A: 1}
        for k in prev.keys():
            v = prev[k]
            newv = (k + A) % M
            if newv in ccc:
                ccc[newv] += v
            else:
                ccc[newv] = v
        c += ccc[0] if 0 in ccc else 0
        prev = ccc
    return c


def main():
    N, M = [int(a) for a in input().split()]
    As = [int(a) for a in input().split()]
    print(f(As, M))


if __name__ == '__main__':
    main()
