codeparrot/codecomplex huggingface dataset:
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;


public class A {

    /**
     * @param args
     */
    public static void main(String[] args) {
        HomeWorks hw = new HomeWorks();
        hw.sol();
        hw.print();
    }

}

class HomeWorks {
    HomeWorks(){
        Scanner scr = new Scanner(System.in);
        
        n = scr.nextInt();
        a = scr.nextInt();
        b = scr.nextInt();
        h = new int[n];
        
        for (int i = 0; i < n; i++){
            h[i] = scr.nextInt();
        }
        scr.close();
    }
    
    void sol() {
        Arrays.sort(h);
        int Vasya = h[b-1];
        int Petya = h[b]; 
        
        ans = Petya - Vasya;
        if (ans < 0){
            ans = 0;
        }
        
    }
    
    void print(){
        PrintWriter pw = new PrintWriter(System.out);
        pw.println(ans);
        pw.flush();
        pw.close();
    }
    
    int ans;
    
    int[] h;
    
    int n;
    int a;
    int b;
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;


public class A {
    
    public static void main(String[] args) throws Exception {
        int n = nextInt(), b = nextInt(), a = nextInt();
        
        int[] mas = new int[n];
        for(int i = 0; i<n; i++) {
            mas[i] = nextInt();
        }
        Arrays.sort(mas);
        
        if(mas[a - 1] == mas[a]) {
            exit(0);
        }
        
        println(mas[a] - mas[a-1]);
    }
    
    /////////////////////////////////////////////////////////////////
    // IO
    /////////////////////////////////////////////////////////////////
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;
    
    private static boolean FILE=false;
    
    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }
    
    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }
    
    static{
        try {
            out = new PrintWriter(FILE ? (new FileOutputStream("output.txt")) : System.out);
            inB = new BufferedReader(new InputStreamReader(FILE ? new FileInputStream("input.txt") : System.in));
        } catch(Exception e) {e.printStackTrace();}
        in = new StreamTokenizer(inB);
    }
    /////////////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////////////
    // pre - written
    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        out.println(o);
        out.flush();
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    private static final int  INF = Integer.MAX_VALUE;
    private static final int MINF = Integer.MIN_VALUE;
    //////////////////////////////////////////////////////////////////
}
// Problem: 169_A. Chores
// Time complexity: nlogn

/**
 * Write a description of class VK2A here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
import java.util.*;
public class VK2A
{
    public static void main(String args[])
    {
        Scanner S = new Scanner(System.in);
        int n = S.nextInt();
        int a = S.nextInt();
        int b = S.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < n; i++)
            A[i] = S.nextInt();
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n - i - 1; j++)
            {
                if(A[j] < A[j + 1])
                {
                    int temp = A[j];
                    A[j] = A[j + 1];
                    A[j + 1] = temp;
                }
            }
        
            System.out.println(A[a - 1] - A[a]);
        }
 
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class A {

    private void solve() throws IOException {
        int n = nextInt();
        int a = nextInt();
        int b = nextInt();
        
        int[] h = new int[n];
        
        for (int i = 0; i < n; i++)
            h[i] = nextInt();
        
        Arrays.sort(h);
        
        int fstB = h[h.length - a];
        int lstA = h[h.length - a - 1];
        
        pl((fstB - lstA) > 0 ? (fstB - lstA) : 0);
    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main(String [] args){
        Scanner in= new Scanner(System.in);
        int n=in.nextInt();
        int a=in.nextInt();
        int b=in.nextInt();
        int []deals=new int[n];
        for(int i=0; i<n; i++){
            deals[i]=in.nextInt();
        }
        Arrays.sort(deals);
        System.out.println(deals[b]-deals[b-1]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        int mod=1000000007;
        String[] input=in.readLine().split(" ");
        int n=Integer.parseInt(input[0]);
        int a=Integer.parseInt(input[1]);
        int b=Integer.parseInt(input[2]);
        String[] h=in.readLine().split(" ");
        int[] mas=new int[n];
        for(int i=0; i<n; i++){
            mas[i]=Integer.parseInt(h[i]);
        }
        Arrays.sort(mas);
        int l=mas[b-1];
        int r=mas[b];
        int count=0;
        if(l==r) count=0;
        else count=r-l;
        out.println(count);
        out.close();
    }

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class VKRound2Div2Task1 {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] strs = str.split(" ");
		int n = Integer.parseInt(strs[0]);
		int a = Integer.parseInt(strs[1]);
		int b = Integer.parseInt(strs[2]);
		str = br.readLine();
		String[] hs = str.split(" ");
		int[] h = new int[hs.length];
		for(int i=0;i<hs.length;i++){
			h[i] = Integer.parseInt(hs[i]);
		}
		Arrays.sort(h);
		if(h[b-1]==h[b]){
			System.out.println(0);
		}else{
			System.out.println(h[b]-h[b-1]);
		}
		
	}

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.*;

// VK Cup 2012 Round2 Unofficial Div2 Edition
public class Main {
	
	void A(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] h = new int[n];
		for(int i=0; i<n; i++){
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		System.out.println(h[b]-h[b-1]);
	}
	
	public static void main(String[] args) {
		new Main().A();
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class r114 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        ArrayList<Integer> l = new ArrayList<Integer>();
        for (int i = 0 ; i < n; i++) {
            l.add(sc.nextInt());
        }
        Collections.sort(l);
        
        int pet = l.get(n - a);
        int vas = l.get(b - 1);
        
        if (pet <= vas) {
            System.out.println(0);
        }
        else System.out.println(pet - vas);     
        
        sc.close();
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.util.Arrays;

public class Main{

	public static void main(String[] args) throws Exception {
		
		int n = nextInt();
		int a = nextInt();
		int b = nextInt();
		int[] tasks = new int[n];
		for(int i = 0; i < n; i++){
			tasks[i] = nextInt();
		}
		Arrays.sort(tasks);
		exit(tasks[b] - tasks[b-1]);
		
	}
	
	private static PrintWriter out;
	private static BufferedReader inB;
	private static boolean FILE = false; 
	
	static {
		try {
			out = new PrintWriter(FILE ? (new FileOutputStream("output.txt")) : System.out);
			inB = new BufferedReader(new InputStreamReader(FILE ? new FileInputStream("input.txt") : System.in));
		} catch(Exception e) {e.printStackTrace();}
	}
	
	private static StreamTokenizer in = new StreamTokenizer(inB);
	
	private static void exit(Object o) throws Exception {
		out.println(o);
		out.flush();
		System.exit(0);
	}
	private static void println(Object o) throws Exception{
		out.println(o);
		out.flush();
	}
	private static void print(Object o) throws Exception{
		out.print(o);
		out.flush();
	}
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}  
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;        
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class Success {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b=scan.nextInt();
		int[] t=new int[n];
		for(int i=0;i<n;i++)
		{
			t[i]=scan.nextInt();
		}
		Arrays.sort(t);
		System.out.println(t[b]-t[b-1]);
		}
		

	}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class test
{

	public static void main(String[] args)
	{
		new test().run();
	}

	PrintWriter out = null;

	void run()
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();

		int[] h = new int[n];
		for (int i = 0; i < n; i++)
			h[i] = in.nextInt();

		Arrays.sort(h);

		if (h[b] == h[b - 1])
			out.println(0);
		else
			out.println(h[b] - h[b - 1]);
		out.close();
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Михаил
 * Date: 25.03.12
 * Time: 19:03
 * To change this template use File | Settings | File Templates.
 */
public class ProblemOne {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int problemCount = scanner.nextInt();
        int petrCount = scanner.nextInt();
        int vasCount = scanner.nextInt();
        int [] problems = new int[problemCount];
        for (int i = 0; i < problemCount; i++) {
            problems[i] = scanner.nextInt();
            

        }
        Arrays.sort(problems);
        System.out.println(-problems[vasCount - 1] + problems[vasCount]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Mirza
 * Date: 25.03.12
 * Time: 18:51
 * To change this template use File | Settings | File Templates.
 */
public class main {
        static Scanner in; static int next() throws Exception {return in.nextInt();};
    //static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
    //  static BufferedReader in;
    static PrintWriter out;

    public static void main(String[] args) throws Exception {
        in = new Scanner(System.in);
//      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//      in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        int n = next();
        int a = next();
        int b = next();
        int k = 0;
        int i;
        int[] ar = new int[n];
        for(i=0;i<n;i++)
            ar[i]=next();
        Arrays.sort(ar);
        k = ar[n-a]-ar[b-1];
        if(k<0)
            out.print(0);
        else out.print(k);
        out.close();

    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++)
            h[i] = sc.nextInt();

        Arrays.sort(h);
        
        pw.print(h[b]-h[b-1]);
        pw.close();
    }

}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author hheng
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] chores = new int[n];
        for (int i=0; i<n; i++) chores[i] = in.nextInt();
        Arrays.sort(chores);
        out.println(chores[b]-chores[b-1]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.util.*;


public class Contest169ProblemA implements Runnable {

    void solve() throws NumberFormatException, IOException {
        int n = nextInt(), a = nextInt(), b = nextInt();

        ArrayList<Integer> tasks= new ArrayList<Integer>();
        
        for (int i = 0; i < n; ++i){
            tasks.add(nextInt());
        }
        Collections.sort(tasks);

        int l1 = tasks.get(b-1);
        int l2 = tasks.get(b);

        if (l2 - l1 >= 0){
            out.print(l2-l1);
        } else {
            out.print(l2-l1);
        }

    }


    StringTokenizer st;

    BufferedReader in;

    PrintWriter out;


    public static void main(String[] args) {

        new Thread(new Contest169ProblemA()).start();
    }


    public void run() {

        try {
            if (System.getProperty("ONLINE_JUDGE") != null) {
                in = new BufferedReader(new InputStreamReader(System.in));
            } else {
                in = new BufferedReader(new FileReader("input.txt"));
            }

            out = new PrintWriter(System.out);


            solve();


        } catch (Exception e) {

            e.printStackTrace();
            System.out.print(e);
            System.exit(9000);


        } finally {


            out.flush();

            out.close();

        }

    }

    //Получаем следующий токен

    String nextToken() throws IOException {

        while (st == null || !st.hasMoreTokens()) {

            st = new StringTokenizer(in.readLine());

        }

        return st.nextToken();

    }


    int nextInt() throws NumberFormatException, IOException {

        return Integer.parseInt(nextToken());

    }


    long nextLong() throws NumberFormatException, IOException {

        return Long.parseLong(nextToken());

    }


    double nextDouble() throws NumberFormatException, IOException {

        return Double.parseDouble(nextToken());

    }


}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[]parts = br.readLine().split("\\s+");
		int n = Integer.parseInt(parts[0]);
		int a = Integer.parseInt(parts[1]);
		int b = Integer.parseInt(parts[2]);
		parts = br.readLine().split("\\s+");
		int[]hard = new int[n];
		for(int i = 0; i < n; i++){
			hard[i] = Integer.parseInt(parts[i]);
		}
		Arrays.sort(hard);
		System.out.println(hard[b]-hard[b-1]);
	}
}
// Problem: 169_A. Chores
// Time complexity: nlogn

import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class A {

    int INF = 1 << 28;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long[] chores = new long[n];
        for(int i=0;i<n;i++) chores[i] = sc.nextLong();
        sort(chores);
        System.out.println(chores[b]-chores[b-1]);
    }

    public static void main(String[] args) {
        new A().run();
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.*;
import java.util.*;

/**
 * @author Vaibhav Mittal
 */

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int testCases = 1;
        Task solver = new Task();
        for (int i = 1; i <= testCases; ++i)
            solver.solve(in, out);

        out.close();
    }
}

class Task {
    public void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] complexity = new int[n];
        for (int i = 0; i < n; ++i)
            complexity[i] = in.nextInt();
        Arrays.sort(complexity);
        out.println(complexity[b] - complexity[b - 1]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        
        int[] h = new int[3000];
        
        for(int i = 0; i<n; i++)
            h[i] = in.nextInt();
        
        int l = 0, r = 1000000000, m = 0;
        int ansl = 0, ansr = 0;
        
        while(l<=r){
            m = (l+r)/2;
            
            int ca=0;
            
            for(int i = 0;i<n;i++)
                if (h[i]>m) ca++;
            
            if (ca == a) ansl=m;
            if (ca <= a) r=m-1; else l=m+1;
        }
        l = 0; r = 1000000000;
        while(l<=r){
            m = (l+r)/2;
            
            int ca=0;
            
            for(int i = 0;i<n;i++)
                if (h[i]>m) ca++;
            
            if (ca == a) ansr=m;
            if (ca < a) r=m-1; else l=m+1;
        }
        if (ansl == 0 || ansr==0) System.out.print(0); else
        System.out.print(ansr-ansl+1);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution {
    //<editor-fold desc="input parse" defaultstate="collapsed">

    private static StringTokenizer st;
    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    private static long nextLong() {
        return Long.parseLong(st.nextToken());
    }

    private static int nextInt() {
        return Integer.parseInt(st.nextToken());
    }

    private static double nextDouble() {
        return Double.parseDouble(st.nextToken());
    }

    private static short nextShort() {
        return Short.parseShort(st.nextToken());
    }

    private static byte nextByte() {
        return Byte.parseByte(st.nextToken());
    }

    private static void initTokenizer() throws Exception {
        st = new StringTokenizer(reader.readLine());
    }

    //</editor-fold>

    public static void main(String[] args) throws Exception {
        initTokenizer();

        int n = nextInt();
        int a = nextInt();
        int b = nextInt();

        int[] h = new int[n];

        initTokenizer();

        for (int i = 0; i < n; i++) {
            h[i] = nextInt();
        }

        Arrays.sort(h);

        System.out.print(h[b] - h[b - 1]);
    }
}
// Problem: 169_A. Chores
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st;

        st = new StringTokenizer(in.readLine());
        
        int n = Integer.parseInt(st.nextToken()),
            a = Integer.parseInt(st.nextToken()),
            b = Integer.parseInt(st.nextToken());
        
        st = new StringTokenizer(in.readLine());
        
        ArrayList<Integer> A = new ArrayList<Integer>();
        
        for (int i = 0 ; i < n ; i++) {
            A.add(Integer.parseInt(st.nextToken()));
        }
        
        Collections.sort(A);
        
        System.out.println(A.get(b) - A.get(b - 1));
    }
}