use std::io::*;
use std::str::FromStr;

//*
fn abc(n:i64, m:i64, a: Vec<i64>) -> i64 {
    let mut cnt: i64 = 0;
    for l in (0..n) {
        for r in (l..n) {
            let sums: i64 = a.iter().enumerate().filter(|&(i, _)| (l as i64 <= i as i64) & (i as i64 <= r as i64)).map(|(_, &x)| x).sum();
            if sums % m ==0 {
                cnt += 1;
            }
        }
    }
    return cnt
}


fn main() {

    let n: i64 = read();
    let m: i64 = read();

    let a: Vec<(i64)> = (0..n).map(|_|read()).collect();

    let result = abc(n,m,a);
    
    println!("{}", result);
}

//*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}