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

fn main() {
    let n: usize = read();
    let m: u64 = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let mut ans = 0;

    for i in 0..n {
        let mut sum = 0;
        for j in i..n {
            sum += a[j];
            if sum % m == 0 {
                ans += 1;
            }
        }
    }

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
