from collections import Counter

from itertools import accumulate





def solve(string):

    n, m, *a = list(map(int, string.split()))

    a = list(accumulate(a))



    d = Counter(_a % m for _a in a)

    ans = d[0]

    ans += sum(v * (v - 1) // 2 for v in list(d.values()))

    return str(ans)





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

from collections import Counter

from itertools import accumulate





def solve(string):

    n, m, *a = list(map(int, string.split()))

    d = Counter(_a % m for _a in accumulate([0] + a))

    return str(sum(v * (v - 1) // 2 for v in list(d.values())))





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

from collections import Counter
from itertools import accumulate


def solve(string):
    n, m, *a = list(map(int, string.split()))
    a = list(accumulate(a))
    d = Counter(_a % m for _a in a)
    ans = d[0]
    ans += sum(v * (v - 1) // 2 for v in list(d.values()))
    return str(ans)


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

from collections import Counter
from itertools import accumulate


def solve(string):
    n, m, *a = list(map(int, string.split()))
    d = Counter(_a % m for _a in accumulate([0] + a))
    return str(sum(v * (v - 1) // 2 for v in list(d.values())))


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

-    a = list(accumulate(a)) -    d = Counter(_a % m for _a in a) -    ans = d[0] -    ans += sum(v * (v - 1) // 2 for v in list(d.values())) -    return str(ans) +    d = Counter(_a % m for _a in accumulate([0] + a)) +    return str(sum(v * (v - 1) // 2 for v in list(d.values())))