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(if *state < m {-1} else {*state % m})}).collect();
    sum.insert(0, 0);
    sum.sort();


    let mut ans = 0;
    let mut state = -1;
    let mut state_num = 0;

    for k in sum.iter().filter(|x| {**x != -1}) {
        if *k == state {
            state_num += 1;
        } else {
            ans += state_num * (state_num - 1) / 2;
            state_num = 1;
        }
        state = *k;
    }
    ans += (state_num - 1) * state_num / 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()
}