import future, strutils


proc nextString: string =
    result = ""
    while not endOfFile stdin:
        let c = readChar stdin
        if c == ' ' or c == "\n"[0]: break
        elif c != '\r': add result, c


proc nextInt: int =
    parseInt nextString()


let
    n, m = nextInt()
    A = lc[nextInt() | (i <- 0 ..< n), int]

var
    B = A
    cnt = 0


proc main: void =
    for i in 0 ..< n - 1:
        B[i + 1] += B[i]

    for i in 0 ..< n:
        for j in i ..< n:
            let k = if i == 0: 0 else: B[i - 1]
            if (B[j] - k) mod m == 0:
                inc cnt
    echo cnt


when ismainmodule:
    main()
