#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

n, m = map(int, raw_input().split())
A = map(int, raw_input().split())
dic = {}
dic[0] = 1
S = 0
for num in A:
    S += num
    S %= m
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
ans = 0
for key in dic:
    num = dic[key]
    ans += num * (num - 1) / 2
print ans