object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n,k = sc.nextInt
  val imap = Seq.fill(n)(sc.nextLong).zipWithIndex.map(_.swap).toMap
  
  val sum = (0 to n-1).combinations(k).toSeq.map{ s =>
    val mapped = s.map(imap(_))
    mapped.max - mapped.min
  }

  println(sum.sum % 1000000007)
}