import java.util
import java.util.Scanner

import scala.util.Sorting

/**
  * lewin のコードが速かったのでscalaだとどれぐらいの速度が出るのかみてみる
  */
object Main {
  def main(args: Array[String]): Unit = {
    val in = new Scanner(System.in)
    val n = in.nextInt()
    val k = in.nextInt()
    val q = in.nextInt()
    val arr = Array.fill(n)(in.nextInt())
    val solver = new TaskE
    println(solver.solve(n, k, q, arr))
  }

  class TaskE {
    def get(arr: Array[Int], k: Int, sm: Int, big: Int): Int = {
      var good = 0
      var tot = 0
      var ans = 0
      for {
        j <- arr.indices
      }{
        if (arr(j) < sm) {
          ans += Math.max(0, Math.min(tot - k + 1, good))
          good = 0
          tot = 0
        }
        else {
          tot += 1
          if (arr(j) <= big) good += 1
        }
      }
      ans += Math.max(0, Math.min(tot - k + 1, good))
      ans
    }

    def solve(n: Int, k: Int, q: Int, arr: Array[Int]): Int = {
      val brr = util.Arrays.copyOf(arr, arr.length)
      Sorting.quickSort(brr)
      var ret = brr(q - 1) - brr(0)
      for {
        small <- brr.indices
      } {
        var lo = small
        var hi = brr.length
        while (lo < hi) {
          val mid = (lo + hi) / 2
          if (get(arr, k, brr(small), brr(mid)) >= q) hi = mid
          else lo = mid + 1
        }
        if (lo < brr.length) ret = Math.min(ret, brr(lo) - brr(small))
      }
      ret
    }
  }

}

