use std::io::*;
use std::str::*;

fn main() {
    let n: usize = read_one();
    let m: i64 = read_one();
    let a: Vec<i64> = read_vec();

    let mut sum: Vec<i64> = a.iter().scan(0, |state, &x| {*state = *state + x; Some(*state)}).collect();
    sum.insert(0, 0);
    let mut sum_mod: Vec<i64> = sum.iter().map(|&x| {x % m}).collect();
    let mut sum_set: Vec<i64> = sum_mod.clone();
    sum_set.sort();
    sum_set.dedup();


    let mut ans = 0;

    for k in sum_set.iter() {
        let s: i64 = sum_mod.iter().map(|&x| {if x == *k {1} else {0}}).sum();
        ans += s * (s - 1) / 2;
    }


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

fn read_one<T: std::str::FromStr>() -> T {
    let mut s = stdin().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}