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 mut vec:Vec<i32> = a.iter().map(|x| x % m).collect();
    let mut sumVec: Vec<i32> = Vec::with_capacity(n as usize);
    let mut sum = 0;
    for i in 0..n {
        sum += vec[i as usize];
        sumVec.push(sum.clone());
    }
    sum = 0;
    for i in 0..n{
        let tup = &sumVec.split_at_mut(i as usize);
        tup.1.iter().for_each(|x| {
            if((x-sum) % m == 0) {result += 1;}
        });
        sum += vec[i as usize];
    }

    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()
}