import java.io.*;
import java.util.*;
class Main {
private static int n, k;
private static int[] numbers;
private static Random random;
private static void readData(Scanner scanner) {
n = scanner.nextInt();
k = scanner.nextInt();
numbers = new int[n];
for (int i = 0; i < n; i++)
numbers[i] = scanner.nextInt();
}
private static int kthElement(int left, int right, int k) {
if (left > right) return -1;
if (left == right) return numbers[left];
int pivotIndex = random.nextInt(right - left + 1) + left;
int pivot = numbers[pivotIndex];
int i = left;
int j = right;
while (i <= j) {
while (numbers[i] < pivot && i < right) i++;
while (numbers[j] > pivot && j > left) j--;
if (i <= j) {
int aux = numbers[i];
numbers[i] = numbers[j];
numbers[j] = aux;
i++;
j--;
}
}
int lowerValues = j - left + 1;
if (lowerValues >= k) return kthElement(left, j, k);
return kthElement(j + 1, right, k - lowerValues);
}
public static void main(String[] args) {
try {
File inputFile = new File("sdo.in");
File outputFile = new File("sdo.out");
FileInputStream inputStream = new FileInputStream(inputFile);
Scanner scanner = new Scanner(inputStream);
readData(scanner);
scanner.close();
inputStream.close();
random = new Random();
FileOutputStream outputStream = new FileOutputStream(outputFile);
PrintWriter writer = new PrintWriter(outputStream);
writer.print(kthElement(0, n - 1, k));
writer.print('\n');
writer.close();
outputStream.close();
} catch(IOException e) {};
}
}