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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut seq = vec![0; n];
    let mut cnts = vec![0; m];
    cnts[0] = 1;
    let mut ans = 0;
    let mut sum = 0;
    for i in 0..n {
        seq[i] = read::<usize>();
        sum = (sum + seq[i]) % m;
        ans += cnts[sum];
        cnts[sum] += 1;
    }
    println!("{}", ans);
}
