use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

use std::collections::HashMap;
fn count<T>(v: T) -> HashMap<T::Item, u64>
where
    T: Iterator,
    T::Item: std::cmp::Eq + std::hash::Hash,
{
    let mut map = HashMap::new();
    for i in v {
        map.entry(i).and_modify(|v| *v += 1).or_insert(1);
    }
    map
}

fn main() {
    let (_n, m) = input!(u64, u64);
    let a = input!(u64,);
    let mut cumsum: Vec<_> = vec![0];
    cumsum.extend(a.iter().scan(0, |state, &x| {
        *state = *state + x;
        Some(*state % m)
    }));
    let cnt = count(cumsum.iter());
    let ans = cnt.values().fold(0, |s, v| s + v * (v - 1) / 2);
    println!("{}", ans);
}
