n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a = a.each_with_object(Hash.new(0)) { |v, h| h[v] += 1 }
keys = a.keys.sort

sum = 0

def c(n, m)
  n.downto(n - m + 1).inject(:*) / m.downto(1).inject(:*)
end

keys.each_with_index do |s, index|
  keys.drop(index + 1).each do |t|
    comb = c(keys.map { |k| a[k] }.inject(:+), k) - c(a[s], k) - c(a[t], k)
    sum += (t - s) * comb % (10 ** 9 + 7)
  end
end

p sum
