fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let line: Vec<i64> = read_vec();
    let (n, m) = (line[0], line[1]);
    let sweets: Vec<i64> = read_vec();
    let mut count = 0;
    for r in 0 .. n {
        let mut sum = 0;
        for l in r .. n {
            sum += sweets[l as usize];
            if sum % m == 0 {
                count += 1;
            }
        }
    }
    println!("{}", count);
}
