use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let m = input::<i64>();
    let a = (0..n).map(|_| input()).collect::<Vec<i64>>();

    let mut sum = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = (sum[i] + a[i]) % m;
    }

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