fn main() {
    let l1 = read_vec::<i32>();
    let l2 = read_vec::<i32>();
    println!("{}", q4(l1[0], l1[1], l2));
}

fn q4(n: i32, m: i32, a: Vec<i32>) -> i32 {
    let mut result = 0;
    let vec:Vec<i32> = a.iter().map(|x| x % m).collect();
    for i in 0..n {
        let mut num = 0;
        for j in i..n {
            num += vec[j as usize];
            if(num % m == 0){
                result += 1;
            }
        }
    }
    return result;
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}