# Original solution
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list([int(x)-1 for x in stdin.readline().split()])
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    if n % k:
        print((1))
    else:
        print((0))
    return

#B
def B():
    n = II()
    dp = [0] * (100 + 1)
    dp[4] = 1
    dp[7] = 1
    for i in range(8,n + 1):
        if dp[i - 4] or dp[i - 7]:
            dp[i] = 1
    print((["No", "Yes"][dp[n]]))
    return

#C
def C():
    n = II()
    ans = []
    if n == 0:
        print((0))
    while n:
        ans.append("{}".format(n % 2))
        n = (n-1) // -2
    print(("".join(ans[::-1])))
    return

#D
def D():
    n, m = LI()
    a = LI()
    a = list([x % m for x in a])
    a = [0] + a
    d = defaultdict(int)
    ans = 0
    for i in range(1, n + 1):
        a[i] += a[i - 1]
        a[i] %= m
        d[a[i]] += 1
    d[0] += 1
    for value in list(d.values()):
        ans += value * (value - 1) // 2
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


# Optimized solution
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list([int(x)-1 for x in input().split()])
def II(): return int(eval(input()))
def IF(): return float(eval(input()))
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
  n, m = LI()
  a = LI()
  for i in range(n-1):
    a[i + 1] += a[i]
  a = [i % m for i in a]
  d = defaultdict(int)
  for i in range(n):
    d[a[i]] += 1
  ans = d[0]
  for i in list(d.values()):
    ans += i * (i-1) // 2
  print(ans)

  return

#B
def B():
  return

#C
def C():
  return

#D
def D():
  return

#E
def E():
  return

#F
def F():
  return

#G
def G():
  return

#H
def H():
  return

#Solve
if __name__ == '__main__':
  A()