macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    n: usize,
    k: usize,
    a:[i64; n]
    }
    let mut a = a;
    a.sort();
    let mc = a.iter().filter(|&&x| x < 0).count();
    let pc = a.iter().filter(|&&x| x > 0).count();
    let ml = &a[..mc];
    let pl = &a[a.len() - pc..];
    let mk = mc * pc;
    let pk = (n * n - n) / 2 - ((mc * mc - mc) / 2 + (pc * pc - pc) / 2);
    let ans = if k <= mk {
        m_ans(k, &ml, &pl)
    } else if k > pk {
        p_ans(k - pk, &ml, &pl)
    } else {
        0
    };
    println!("{}", ans);
}

fn m_ans(k: usize, ml: &[i64], pl: &[i64]) -> i64 {
    let mut l = -i64::max_value();
    let mut r = -1;
    while l + 1 < r {
        let mid = (l + r) / 2;
        let mut j = 0;
        let mut count = 0;
        for i in 0..pl.len() {
            while j < ml.len() && ml[j] * pl[i] <= mid {
                j += 1;
            }
            count += j;
        }
        if count < k {
            l = mid;
        } else {
            r = mid;
        }
    }
    r
}

fn p_ans(k: usize, ml: &[i64], pl: &[i64]) -> i64 {
    let mut l = 0;
    let mut r = i64::max_value();
    while l + 1 < r {
        let mid = (l + r) / 2;
        let mut j = 0;
        let mut count = 0;
        for i in (0..pl.len()).rev() {
            while j < i && pl[i] * pl[j] <= mid {
                j += 1;
            }
            count += j;
            if i == j {
                count += (i * i - i) / 2;
                break;
            }
        }
        count += (ml.len() * ml.len() - ml.len()) / 2;
        j = 0;
        for i in (0..ml.len()).rev() {
            while j < i && ml[i] * ml[j] > mid {
                j += 1;
            }
            count -= j;
            if j == i {
                count -= (i * i - i) / 2;
                break;
            }
        }
        if count < k {
            l = mid;
        } else {
            r = mid;
        }
    }
    r
}


Measured memory_bytes: 6396