#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
   read,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      mut a: [usize; n]
   }

   a[0] %= m;
   for i in 1..n {
      a[i] += a[i - 1];
      a[i] %= m;
   }

   let mut ans = 0;
   let mut c = vec![0usize; m];
   c[0] = 1;
   for i in 0..n {
      ans += c[a[i]];
      c[a[i]] += 1;
   }
   println!("{}", ans);
}
