use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }
    let mut acc = 0;
    let mut hs = HashMap::new();
    hs.insert(0, 1);
    for i in 0..n {
        acc = (a[i] + acc) % m;
        if hs.contains_key(&acc) {
            hs.insert(acc, hs.get(&acc).unwrap() + 1);
        } else {
            hs.insert(acc, 1);
        }
    }

    let mut res = 0usize;
    for val in hs.values() {
        res += val * (val - 1) / 2;
    }
    println!("{}", res);
}
