use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0] as usize;
    let m = line[1];
    let a: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut b = vec![0; n+1];
    let mut memo = HashMap::with_capacity(n);
    memo.insert(0, 1);
    let mut ans = 0;
    for i in 0..n {
        b[i+1] = (b[i] + a[i])%m;
        ans += memo.get(&b[i+1]).unwrap_or(&0);
        memo.insert(b[i+1], memo.get(&b[i+1]).unwrap_or(&0) + 1);
    }

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