use std::io::stdin;

fn main() {
    let mut nm = String::new();
    stdin().read_line(&mut nm).unwrap();
    let nm: Vec<usize> = nm.trim().split_whitespace().flat_map(str::parse).collect();
    let (n, m) = (nm[0], nm[1]);

    let mut candies = String::new();
    stdin().read_line(&mut candies).unwrap();
    let candies: Vec<usize> = candies.trim().split_whitespace().flat_map(str::parse).collect();

    println!("{}", solve(n, m, candies));
}

fn solve(n :usize, m: usize, candies: Vec<usize>) -> usize {
    let mut ca = Vec::with_capacity(n + 1);
    ca.push(0);
    candies.into_iter().fold(0, |acc, v|{
        ca.push(acc + v);
        acc + v
    });

    let mut res = 0;
    for l in 0..n+1 {
        for r in l+1..n+1 {
            if (ca[r] - ca[l]) % m == 0 {
                res += 1;
            }
        }
    }
    res
}
