import sequtils, strutils, algorithm, math, future, sets, tables, hashes, intsets, deques
let read = iterator : string {.closure.} = (while true: (for s in stdin.readLine.split : yield s))

var
    n,m = read().parseint
    a = newseqwith(n , read().parseint)
    acm = newseqwith(n + 1, 0)
    cntt = initTable[int, int]()
    cnt = 0

cntt[0] = 1
for i in  0 ..< n:
    acm[i + 1] = acm[i] + a[i]
    acm[i + 1] = acm[i + 1] mod m
    if acm[i + 1] notin cntt:
        cntt[acm[i + 1]] = 1
    else:
        cnt += cntt[acm[i + 1]]
        cntt[acm[i + 1]] += 1

echo cnt