use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) = get!(usize, usize);
    let v = get!([usize]);
    let mut sum = vec![0; n + 1];
    sum[0] = 0;
    for i in 1..n + 1 {
        sum[i] = (sum[i - 1] + v[i - 1]) % m;
    }
    //eprintln!("sum: {:?}", sum);
    let mut map = HashMap::new();
    for i in 0..n + 1 {
        *map.entry(sum[i]).or_insert(0) += 1;
    }
    //eprintln!("map: {:?}", map);
    let mut ans = 0;
    for i in 0..n + 1 {
        let val = *map.get(&sum[i]).unwrap_or(&0);
        //eprintln!("sum[i]: {}, val: {}", sum[i], val);
        if 2 <= val {
            ans += (1 + val - 1) * (val - 1) / 2;
            *map.get_mut(&(sum[i] % m)).unwrap() = 0;
        }
    }
    println!("{}", ans);
}
