#!/usr/bin/env python3
#ABC105 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    b = list(accumulate(a[i:]))
    b = list(map(lambda x:x%m,b))
    b.sort()
    ans += bisect.bisect_right(b,0) 
print(ans)
