pub struct Scan(Box<dyn Iterator<Item = &'static str>>);
impl Scan {
   fn new() -> Self {
      let mut buf = String::new();
      let read_line = move || {
         std::io::stdin().read_line(&mut buf).unwrap();
         Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
      };
      Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
   }

   pub fn word<T: std::str::FromStr>(&mut self) -> T {
      self.0.next().unwrap().parse().ok().unwrap()
   }

   pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
      std::iter::repeat_with(|| self.word()).take(len).collect()
   }
}

fn main() {
   let mut scan = Scan::new();
   let n: usize = scan.word();
   let m: usize = scan.word();
   let mut a = vec![0; n + 1];

   for i in 0..n {
      let _a: usize = scan.word();
      a[i + 1] = (a[i] + _a) % m;
   }

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