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

pub 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")
}

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let m: i64 = read();
    let mut a: Vec<i64> = vec![];

    for _ in 0..n {
        a.push(read());
    }

    let mut sum = 0;
    let mut ans = 0;
    let mut b: HashMap<i64, i64> = HashMap::new();
    b.insert(0, 1);
    let mut c: Vec<i64> = vec![];
    for i in 0..a.len() {
        sum += a[i];
        match b.get(&(sum % m)) {
            Some(s) => ans += s,
            None => (),
        }
        let current = b.entry((sum % m)).or_insert(0);
        *current += 1;
    }
    println!("{}", ans);
}
