//#include <ext/pb_ds/assoc_container.hpp> 
     //#include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e18;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
   //  using namespace __gnu_pbds;
     //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
    
     int n,k;
     int a[200001];
    
  
    
    set<int> s;
    unordered_map<int,int> m1;
    bool check(int mid)
    {
     
        
        int x=0;
        for(int i=1;i<=n;++i)
        {
            if(a[i]==0)
            {
                if(mid>=0)
                {
                    x+=n-1;
                }
                continue;
            }
           
            int temp=mid/a[i];
            if(a[i]<=0 and mid<=0)
            {
                temp=(mid+a[i]+1)/a[i];
                if(temp<=a[1])
                {
                    x+=n;
                      if(a[i]>=temp)
                    x--;
                    continue;
                }
                auto it=s.lower_bound(temp);
                it--;
                int temp1=*it;
                x+=n-m1[temp1];
                if(a[i]>=temp)
                    x--;
            }
            else  if(a[i]<=0 and mid>=0)
            {
                int pre=temp;
                if(temp<=a[1])
                {
                    x+=n;
                      if(a[i]>=temp)
                    x--;

                    continue;
                }
                auto it=s.lower_bound(temp);
                it--;
                int temp1=*it;
                x+=n-m1[temp1];
                if(a[i]>=temp)
                    x--;
            }
            else if(a[i]>=0 and mid<=0)
            {
                temp=(mid-(a[i]-1))/a[i];
                // x+=o.order_of_key({temp,1e9});
                // if(a[i]<=temp)
                // x--;   
                 if(temp<a[1])
                {
                    // x+=n;
                    //   if(a[i]<=temp)
                    // x--;

                    continue;
                }
                auto it=s.upper_bound(temp);
                it--;
                int temp1=*it;
                x+=m1[temp1];
                if(a[i]<=temp)
                    x--;
            }
            else
            {
              if(temp<a[1])
                {
                    continue;
                }
                auto it=s.upper_bound(temp);
                it--;
                int temp1=*it;
                x+=m1[temp1];
                if(a[i]<=temp)
                    x--;
            }   
           
        }
        
        x/=2;
        if(x<=(k-1))
            return true;
        return false;
    }
    int32_t main()
    {
        IOS
   
      
       cin>>n>>k;
    
     
       for(int i=1;i<=n;++i)
       {
            cin>>a[i];
       }
       sort(a+1,a+n+1);
   
       for(int i=1;i<=n;++i)
       {
          
            m1[a[i]]=i;
            s.insert(a[i]);
       }
       
      
       int lo=-1e18,hi=1e18,ans=-1e18;
       while(lo<hi)
       {
            int mid=(lo+hi)/2;
             int x=0;
        for(int i=1;i<=n;++i)
        {
            if(a[i]==0)
            {
                if(mid>=0)
                {
                    x+=n-1;
                }
                continue;
            }
           
            int temp=mid/a[i];
            if(a[i]<=0 and mid<=0)
            {
                temp=(mid+a[i]+1)/a[i];
                if(temp<=a[1])
                {
                    x+=n;
                      if(a[i]>=temp)
                    x--;
                    continue;
                }
                auto it=s.lower_bound(temp);
                it--;
                int temp1=*it;
                x+=n-m1[temp1];
                if(a[i]>=temp)
                    x--;
            }
            else  if(a[i]<=0 and mid>=0)
            {
                int pre=temp;
                if(temp<=a[1])
                {
                    x+=n;
                      if(a[i]>=temp)
                    x--;

                    continue;
                }
                auto it=s.lower_bound(temp);
                it--;
                int temp1=*it;
                x+=n-m1[temp1];
                if(a[i]>=temp)
                    x--;
            }
            else if(a[i]>=0 and mid<=0)
            {
                temp=(mid-(a[i]-1))/a[i];
                // x+=o.order_of_key({temp,1e9});
                // if(a[i]<=temp)
                // x--;   
                 if(temp<a[1])
                {
                    // x+=n;
                    //   if(a[i]<=temp)
                    // x--;

                    continue;
                }
                auto it=s.upper_bound(temp);
                it--;
                int temp1=*it;
                x+=m1[temp1];
                if(a[i]<=temp)
                    x--;
            }
            else
            {
              if(temp<a[1])
                {
                    continue;
                }
                auto it=s.upper_bound(temp);
                it--;
                int temp1=*it;
                x+=m1[temp1];
                if(a[i]<=temp)
                    x--;
            }   
           
        }
        x/=2;
            if(x<=(k-1))
            {
                lo=mid;
                if(ans==lo)
                    break;
                ans=lo;
            }
            else
                hi=mid-1;
       }
       if(check(ans+1))
        ans++;
    cout<<ans+1<<endl;


    }       

Measured memory_bytes: 19912