source_code: import java.util.Arrays;
  import java.util.Scanner;
  
  public class A {
      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a = sc.nextInt();
          int b = sc.nextInt();
          int[] ar = new int[n];
          for (int i = 0; i < n; i++) {
              ar[i] = sc.nextInt();
          }
          Arrays.sort(ar);
          if (ar[b-1] == ar[b ]) {
              System.out.println(0);
          } else {
              System.out.println(ar[b ] - ar[b-1]);
          }
      }
  }
  