use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashMap;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (_, m) = (line[0], line[1]);

    let a: Vec<usize> = read_as_vec();
    let mut b: Vec<usize> = vec![0];
    let mut sum = 0;
    for elem in a{
        sum = (sum + elem)%m;
        b.push(sum);
    }


    let mut mod_hash = HashMap::new();

    for elem in b{
        *mod_hash.entry(elem).or_insert(0) += 1;
    }

    //println!("{:?}", mod_hash);

    let mut ans = 0;

    for (_, value) in mod_hash{
        ans += value*(value-1)/2
    }

    println!("{}", ans);
}
