#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, M = get_ints
A = get_ints

ax = A.map { |a| a % M }

def cumulative_sum(arr)
  arr.reduce([0]) do |prev, cur|
    prev.push(prev.last + cur)
    prev
  end
end

ruiseki = cumulative_sum(ax).map { |x| x % M }

count = 0

kosu = Array.new(M, 0)
ruiseki[1..].each do |x|
  count += kosu[x]
  kosu[x] += 1
end
count += kosu[0]

# kosu.each do |x|
#   next if x <= 1
#   count += (x * (x-1))/2
# end

puts count
