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

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, m) : (usize, usize) = (read(), read());
    let mut a : Vec<usize> = vec![0; n];
    for i in 0..n {
        a[i] = read();
    }

    let mut sum = 0;
    let mut map = HashMap::new();
    map.insert(0, 1);
    for i in 0..n {
        sum = (sum + a[i]) % m;
        if map.contains_key(&sum) {
            *map.get_mut(&sum).unwrap() += 1;
        } else {
            map.insert(sum, 1);
        }
    }
    let mut ans = 0;
    for value in map.values() {
        ans += (value * (value - 1)) / 2;
    }
    println!("{}", ans);
}
