use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut map = std::collections::HashMap::new();
    let mut ans = 0;
    let mut now = 0;
    map.insert(0, 1);
    for i in 0..n {
        now = (now + a[i]) % m;
        let p = map.entry(now).or_insert(0);
        ans += *p;
        *p += 1;
    }
    println!("{}", ans);
}
