#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<map>
typedef long long LL;
int plice[1000005];
bool check(LL mid);
int  dfs(int nc,int mid);
LL n,m;
using namespace std;
int  ac[10000001];
int t = 0;
int vis[10000001];
const int BufferSize=1<<16;
char buffer[BufferSize],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,BufferSize,stdin);
        tail=(head=buffer)+l;
    }
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
int main(void)
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    while(scanf("%lld %lld",&n,&m)!=EOF)
    {
        LL sum = 0;
        t = 1;LL maxx = 0;
        for(int i = 0; i < n; i++)
        {
            plice[i] = read();
            sum += plice[i];
            maxx = max((LL)plice[i],maxx);
        }
        if(sum < m)printf("-1\n");
        else
        {
            LL  l = 1;
            LL r = maxx;
            LL id = -1;
            while(l <= r)
            {
                LL  mid = (l + r)/2;
                if(check(mid))
                    l = mid+1,id = mid;
                else r = mid-1;
                t++;
                // printf("%lld\n",mid);
            }
            printf("%lld\n",id);
        }
    }
    return 0;
}
bool check(LL mid)
{
    LL cn = 0;
    int i;//printf("%d\n",mid);
    for(i = 0; i < n; i++)
    {
        if(plice[i] == mid)
        {
            cn++;
            vis[mid] = t;
            ac[mid] = 1;
        }
        else if(plice[i] > mid)
        {
            cn+=(LL)dfs(plice[i],mid);
        }
    }//if(mid == 1)printf("%lld\n",cn);
    if(cn >= m)return true;
    else return false;
}
int  dfs(int nc,int mid)
{
    if(t == vis[nc])return ac[nc];
    vis[nc] = t;
    if(nc < mid)return ac[nc] = 0;
    if(nc%2)
    {   if(nc/2 < mid)return ac[nc] = 1;

        return ac[nc] = dfs(nc/2,mid)+dfs(nc/2+1,mid);
    }
    else
    {if(nc/2 < mid) return ac[nc] = 1;
    return ac[nc] = (LL)2*dfs(nc/2,mid);}
}
//


#include<bits/stdc++.h>
#define nn 10000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],m[nn];

int check(int val,int c)
{
    if(m[val])
        return m[val];
    if(val<c)
        return 0;
    if(val==c)
        return 1;
    if(val%2)
        return max(1,check(val/2,c)+check(val-val/2,c));
    else
        return max(1,2*check(val/2,c));
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        t=0;
        for(int i=0;i<n;i++)
        {
            if(mid>a[i])
                continue;
            t+=check(a[i],mid);
            if(t>=k)
                break;
        }
        memset(m,0,sizeof m);
        if(t>=k)
            l=mid;
        else
            r=mid-1;
    }
    if(l)
        cout<<l<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<28;i++)
    {
        p[i]=p[i-1]*2;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[27],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=ans+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((int)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(int)(a[i]/mid))/2;
        }
        if(t>=k)
            ans=mid;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

ll a[nn],p[70];

int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    ll l=0,r=10000100;
    ll mid;
    ll ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[49],(ll)(a[i]/mid))/2ll;
        }
        if(t>=k)
        {
            l=mid+1;
            ans=mid;
        }
        else
            r=mid;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=l;
    if(mid)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<26;i++)
    {
        p[i]=p[i-1]*2;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=ans+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((int)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(int)(a[i]/mid))/2;
        }
        if(t>=k)
            ans=mid;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<28;i++)
    {
        p[i]=p[i-1]*2;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            int j;
            for(j=0;j<28;j++)
                if(p[j]>(ll)(a[i]/mid))
                    break;
            t+=p[j-1];
            if(t>=k)
                break;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=ans+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((int)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[27],(int)(a[i]/mid))/2;
            if(t>=k)
                break;
        }
        if(t>=k)
            ans=mid;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<38;i++)
        p[i]=p[i-1]*2;
    int l=0,r=100001000;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            int j;
            for(j=0;j<38;j++)
                if(p[j]>(ll)(a[i]/mid))
                    break;
            t+=p[j-1];
            if((mid*p[j])==a[i]+1 && j>=2)
                t+=p[j-2];
            if(t>=k)
                break;
        }
        if(t>=k)
            l=mid;
        else
            r=mid-1;
    }
    if(l)
        cout<<l<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=r;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            ans=max(ans,mid);
        }
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid+1;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=mid+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            ans=max(ans,mid);
        }
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<28;i++)
    {
        p[i]=p[i-1]*2;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            int j;
            for(j=0;j<28;j++)
                if(p[j]>(ll)(a[i]/mid))
                    break;
            t+=p[j-1];
            if(t>=k)
                break;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=ans+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((int)(a[i]/mid)==0)
                continue;
            int j;
            for(j=0;j<28;j++)
                if(p[j]>(ll)(a[i]/mid))
                    break;
            t+=p[j-1];
            if(t>=k)
                break;
        }
        if(t>=k)
            ans=mid;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int check(int val,int c)
{
    if(val<c)
        return 0;
    if(val==c)
        return 1;
    if(val%2)
        return max(1,check(val/2,c)+check(val-val/2,c));
    else
        return max(1,2*check(val/2,c));
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<38;i++)
        p[i]=p[i-1]*2;
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        t=0;
        for(int i=0;i<n;i++)
        {
            t+=check(a[i],mid);
        }
        if(t>=k)
            l=mid;
        else
            r=mid-1;
    }
    if(l)
        cout<<l<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid+1;
            ans=mid;
        }
        else
            r=mid;
    }
    mid=ans+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            ans=mid;
        }
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<28;i++)
    {
        p[i]=p[i-1]*2;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[27],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    mid=ans+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((int)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[27],(int)(a[i]/mid))/2;
        }
        if(t>=k)
            ans=mid;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 10000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],m[nn];

int check(int val,int c)
{
    if(m[val])
        return m[val];
    if(val<c)
        return 0;
    if(val==c)
        return 1;
    if(val%2)
        m[val]= max(1,check(val/2,c)+check(val-val/2,c));
    else
        m[val]= max(1,2*check(val/2,c));
    return m[val];
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        t=0;
        for(int i=0;i<n;i++)
        {
            t+=check(a[i],mid);
            if(t>=k)
                break;
        }
        for(int i=0;i<nn;i++)
        {
            m[i]=0;
        }
        if(t>=k)
            l=mid;
        else
            r=mid-1;
    }
    if(l)
        cout<<l<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    ll l=0,r=10000100;
    ll mid;
    ll ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid;
            ans=mid;
        }
        else
            r=mid-1;
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 10000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],m[nn];

int main()
{
    ios_base::sync_with_stdio(0);
    int n,k;
    int mx=-1;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    int l=0,r=mx+1;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r+1)/2;
        t=0;
        for(int i=0;i<mid;i++)
            m[i]=0;
        for(int i=mid;i<=mx;i++)
        {
            m[i]=m[i/2]+m[(i+1)/2];
            if(!m[i])
                m[i]=1;
        }
        for(int i=0;i<n;i++)
        {
            t+=m[a[i]];
            if(t>=k)
                break;
        }
        if(t>=k)
            l=mid;
        else
            r=mid-1;
    }
    if(l)
        cout<<l<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define nn 1000100
#define ll long long int
#define INF 30000000
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define se second
using namespace std;

int a[nn],p[70];

int main()
{
    ios_base::sync_with_stdio(0);
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=1;
    for(int i=1;i<50;i++)
    {
        p[i]=p[i-1]*2ll;
    }
    int l=0,r=10000100;
    int mid;
    int ans=0;
    ll t;
    while(l<r)
    {
        mid=(l+r)/2;
        if(mid==0)
            break;
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            l=mid+1;
            ans=mid;
        }
        else
            r=mid;
    }
    mid=mid+1;
    if(mid>0)
    {
        t=0;
        for(int i=0;i<n;i++)
        {
            if((ll)(a[i]/mid)==0)
                continue;
            t+=*upper_bound(&p[0],&p[25],(a[i]/mid))/2;
        }
        if(t>=k)
        {
            ans=max(ans,mid);
        }
    }
    if(ans)
        cout<<ans<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll tot=1;
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		if(p&1) c1=c2*2+c1;
		else c2=c2*2+c1;
		p/=2;
	}

	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int c) {
	ll tot=1;
	while(p/2>=c) {
		tot*=2;
		p/=2;
	}
	return tot;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r-l>=1) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll tot=1;
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		if(p&1) c1=c2*2+c1,c2=c1;
		else c2=c2*2+c1;
		p/=2;
	}
	if((p+1)/2>=x) c1=c2*2+c1,c2=0;
	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		ll s=c1,t=c2;
		if(p&1) {
			if((p+1)/2&1) {c1=t*2+s;c2=s;}
			else {c1=s;c2=t*2+s;}
		}
		else {
			if((p/2)&1) {c2=s,c1=t*2+s;}
			else {c2=t*2+s,c1=s;}
		}
		//cout<<"???"<<p<<endl;
		p/=2;
		//cout<<"!!!"<<c1<<' '<<c2<<endl;
	}
	if((x&1)&&(p+1)/2>=x) c1=c2*2+c1,c2=0;
	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	//for(int i=10;i<=20;i++) cout<<"!!!"<<f(i,1)<<endl;
	//f(13,1);
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		ll s=c1,t=c2;
		if(p&1) {
			if((p+1)/2&1) {c1=t*2+s;c2=s;}
			else {c1=s;c2=t*2+s;}
		}
		else {
			if((p/2)&1) {c2=s,c1=t*2+s;}
			else {c2=t*2+s,c1=s;}
		}
		//cout<<"???"<<p<<endl;
		p/=2;
		//cout<<"!!!"<<c1<<' '<<c2<<endl;
	}
	if((p+1)/2>=x) {
		ll s=c1,t=c2;
		if(x&1) c1=t*2+s,c2=0;
		else c2=t*2+s,c1=0;
	}
	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	//for(int i=10;i<=20;i++) cout<<"!!!"<<f(i,1)<<endl;
	//f(13,1);
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		ll s=c1,t=c2;
		if(p&1) {
			if((p+1)/2&1) {c1=t*2+s;c2=s;}
			else {c1=s;c2=t*2+s;}
		}
		else {
			if((p/2)&1) {c2=s,c1=t*2+s;}
			else {c2=t*2+s,c1=s;}
		}
		//cout<<"???"<<p<<endl;
		p/=2;
		//cout<<"!!!"<<c1<<' '<<c2<<endl;
	}
	if((x&1)&&(p+1)/2>=x) c1=c2*2+c1,c2=0;
	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	for(int i=10;i<=20;i++) cout<<"!!!"<<f(i,1)<<endl;
	//f(13,1);
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		ll s=c1,t=c2;
		if(p&1) {
			if((p+1)/2&1) {c1=t*2+s;c2=s;}
			else {c1=s;c2=t*2+s;}
		}
		else {
			if((p/2)&1) {c2=s,c1=t*2+s;}
			else {c2=t*2+s,c1=s;}
		}
		//cout<<"???"<<p<<endl;
		p/=2;
		//cout<<"!!!"<<c1<<' '<<c2<<endl;
	}
	if((p+1)/2>=x) {
		ll s=c1,t=c2;
		if(x&1) c2=t*2+s,c1=s;
		else c1=t*2+s,c2=s;
	}
	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	//for(int i=10;i<=20;i++) cout<<"!!!"<<f(i,1)<<endl;
	//f(13,1);
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int c) {
	ll tot=1;
	while(p/2>=c) {
		tot*=2;
		p/=2;
	}
	return tot;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int c) {
	ll tot=1;
	while(p/2>=c) {
		tot*=2;
		p/=2;
	}
	return tot;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
const double eps=1e-8;
const int maxn=100005;
typedef long long ll;
typedef pair<int,int> pii;

int n;
ll k;
int a[1000005];
ll f(int p,int x) {
	ll tot=1;
	ll c1=0,c2=0;
	if(p&1) c1=1;else c2=1;
	while(p/2>=x) {
		int s=c1,t=c2;
		if(p&1) c2=s,c1=t*2+s;
		else {
			if((p/2)&1) {c2=s,c1=t*2+s;}
			else {c2=t*2+s,c1=s;}
		}
		p/=2;
	}
	if((x&1)&&(p+1)/2>=x) c1=c2*2+c1,c2=0;
	return c1+c2;
}

bool check(int x) {
	ll cnt=0;
	for(int i=0;i<n;i++) {
		if(a[i]>=x)
		cnt+=f(a[i],x);
	}
	if(cnt>=k) return 1;
	return 0;
}

int main() {
	scanf("%d %I64d",&n,&k);
	int l=1,r=0;
	for(int i=0;i<n;i++) scanf("%d",a+i),r=max(r,a[i]);
	r+=10;
	int ans=-1;
	while(r>=l) {
		int m=l+r>>1;
		if(check(m)) ans=m,l=m+1;
		else r=m-1;
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 1000010
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
int n,m,a[maxn],ans,i,maxl,l,r,mid;
int c[10000010];

llg check(llg x)
{
	llg tot=0;
	for (i=1;i<=maxl;i++) c[i]=0;
	for (i=1;i<=n;i++) c[a[i]]++;
	for (i=maxl;i>=x;i--)
	{
		if (i/2>=x)
		{
			c[i/2]+=c[i]*2;
		}
		else
		{
			tot+=c[i];
		}
	}
	if (tot>=m) return 1;else return 0;
}

int main()
{
//	yyj("D");
	cin>>n>>m;
	for (i=1;i<=n;i++) { scanf("%d",&a[i]); r=max(r,a[i]);}
	l=1; maxl=r;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (check(mid)) {l=mid+1; ans=mid;}else {r=mid-1;}
	}
	if (ans==0) ans--;
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 1000010
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
int n,m,a[maxn],ans,i,maxl,l,r,mid;
int c[10000010];

llg check(llg x)
{
	llg tot=0;
	for (i=1;i<=maxl;i++) c[i]=0;
	for (i=1;i<=n;i++) c[a[i]]++;
	for (i=maxl;i>=x;i--)
	{
		if (i/2>=x)
		{
			if (i%2) {c[i/2]+=c[i]; c[i/2+1]+=c[i];}
			else {c[i/2]+=c[i]*2;}
		}
		else
		{
			tot+=c[i];
		}
	}
	if (tot>=m) return 1;else return 0;
}

int main()
{
//	yyj("D");
	cin>>n>>m;
	for (i=1;i<=n;i++) { scanf("%d",&a[i]); r=max(r,a[i]);}
	l=1; maxl=r;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (check(mid)) {l=mid+1; ans=mid;}else {r=mid-1;}
	}
	if (ans==0) ans--;
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 1000010
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,a[maxn],ans,i,maxl,l,r,mid;
llg c[10000010];

llg check(llg x)
{
	llg tot=0;
	for (i=1;i<=maxl;i++) c[i]=0;
	for (i=1;i<=n;i++) c[a[i]]++;
	for (i=maxl;i>=x;i--)
	{
		if (i/2>=x)
		{
			if (i%2) {c[i/2]+=c[i]; c[i/2+1]+=c[i];}
			else {c[i/2]+=c[i]*2;}
		}
		else
		{
			tot+=c[i];
		}
	}
	if (tot>=m) return 1;else return 0;
}

int main()
{
//yyj("D");
	cin>>n>>m;
	for (i=1;i<=n;i++) { scanf("%I64d",&a[i]); r=max(r,a[i]);}
	l=1; maxl=r;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (check(mid)) {l=mid+1; ans=mid;}else {r=mid-1;}
	}
	if (ans==0) ans--;
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 1000010
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
int n,m,a[maxn],ans,i,maxl,l,r,mid;
int c[10000010];

llg check(llg x)
{
	llg tot=0;
	for (i=1;i<=maxl;i++) c[i]=0;
	for (i=1;i<=n;i++) c[a[i]]++;
	for (i=maxl;i>=x;i--)
	{
		if (i/2>=x)
		{
			if (i%2) {c[i/2]+=c[i]; c[i/2+1]+=c[i];}
			else {c[i/2]+=c[i]*2;}
		}
		else
		{
			tot+=c[i];
		}
	}
	if (tot>=m) return 1;else return 0;
}y

int main()
{
//	yyj("D");
	cin>>n>>m;
	for (i=1;i<=n;i++) { scanf("%d",&a[i]); r=max(r,a[i]);}
	l=1; maxl=r;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (check(mid)) {l=mid+1; ans=mid;}else {r=mid-1;}
	}
	if (ans==0) ans--;
	cout<<ans;
	return 0;
}


#include<cstdio>
#include<algorithm>

int n;
long long k;
long long a[1000010];
long long MAX,SUM;

long long divide(long long X,long long d)
{
	if(X<d) return 0;
	if(X<2*d) return 1;
	long long p,q;
	for(p=1;p*d<X;p*=2); q=X-p*d;
	return std::max(p-q,p/2);
}

long long solve(long long l,long long r)
{
	if(l+1==r)
	{
		long long t=0;
		for(int i=0;i<n;i++) t+=divide(a[i],r);
		if(t>=k) return r;
		else return l;
	}

	long long m=(l+r)/2;
	long long t=0;
	for(int i=0;i<n;i++) t+=divide(a[i],m);
	if(t>=k) return solve(m,r);
	else return solve(l,m);
}

int main()
{
	scanf("%d%I64d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%I64d",a+i);
		if(a[i]>MAX) MAX=a[i];
		SUM=SUM+a[i];
	}
	if(k>SUM) printf("-1\n");
	else if(MAX==1) printf("1\n");
	else printf("%I64d\n",solve(1,MAX));

	return 0;
}


#include<cstdio>
#include<algorithm>

int n;
long long k;
long long a[1000010];
long long MAX,SUM;

long long divide(long long X,long long k)
{
	if(X<k) return 0;
	if(X<2*k) return 1;
	long long p,q;
	for(p=1;p*k<X;p*=2); q=X-p*k;
	return std::max(p-q,p/2);
}

long long solve(long long l,long long r)
{
	if(l+1==r)
	{
		long long t=0;
		for(int i=0;i<n;i++) t+=divide(a[i],r);
		if(t>=k) return r;
		else return l;
	}

	long long m=(l+r)/2;
	long long t=0;
	for(int i=0;i<n;i++) t+=divide(a[i],m);
	if(t>=k) return solve(m,r);
	else return solve(l,m);
}

int main()
{
	scanf("%d%I64d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%I64d",a+i);
		if(a[i]>MAX) MAX=a[i];
		SUM=SUM+a[i];
	}
	if(k>SUM) printf("-1\n");
	else if(MAX==1) printf("1\n");
	else printf("%I64d\n",solve(1,MAX));

	return 0;
}


#include<cstdio>
#include<algorithm>

int n;
long long k;
long long a[1000010];
long long MAX,SUM;

long long divide(long long X,long long k)
{
	if(X<k) return 0;
	if(X<2*k) return 1;
	return divide(X/2,k)+divide(X-X/2,k);
}

long long solve(long long l,long long r)
{
	if(l+1==r)
	{
		long long t=0;
		for(int i=0;i<n;i++) t+=divide(a[i],r);
		if(t>=k) return r;
		else return l;
	}

	long long m=(l+r)/2;
	long long t=0;
	for(int i=0;i<n;i++) t+=divide(a[i],m);
	if(t>=k) return solve(m,r);
	else return solve(l,m);
}

int main()
{
	scanf("%d%I64d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%I64d",a+i);
		if(a[i]>MAX) MAX=a[i];
		SUM=SUM+a[i];
	}
	if(k>SUM) printf("-1\n");
	else if(MAX==1) printf("1\n");
	else printf("%I64d\n",solve(1,MAX));

	return 0;
}


#include<cstdio>
#include<algorithm>

long long n,k;
long long a[1000010];
long long MAX,SUM;

long long solve(long long l,long long r)
{
	if(l+1==r)
	{
		long long t=0;
		for(int i=0;i<n;i++) t+=a[i]/r;
		if(t>=k) return r;
		else return l;
	}

	long long m=(l+r)/2;
	long long t=0;
	for(int i=0;i<n;i++) t+=a[i]/m;
	if(t>=k) return solve(m,r);
	else return solve(l,m);
}

int main()
{
	scanf("%I64d%I64d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%I64d",a+i);
		if(a[i]>MAX) MAX=a[i];
		SUM=SUM+a[i];
	}
	if(k>SUM) printf("-1\n");
	else if(MAX==1) printf("1\n");
	else printf("%I64d\n",solve(1,MAX));

	return 0;
}


#include<cstdio>
#include<algorithm>

int n;
long long k;
long long a[1000010];
long long MAX,SUM;

long long divide(long long X,long long d)
{
	if(X<d) return 0;
	if(X<2*d) return 1;
	long long p,q;
	for(p=1;p*d<X;p*=2); q=p*d-X;
	if(p-q>p/2) return p-q;
	else return p/2;
}

long long solve(long long l,long long r)
{
	if(l+1==r)
	{
		long long t=0;
		for(int i=0;i<n;i++) t+=divide(a[i],r);
		if(t>=k) return r;
		else return l;
	}

	long long m=(l+r)/2;
	long long t=0;
	for(int i=0;i<n;i++) t+=divide(a[i],m);
	if(t>=k) return solve(m,r);
	else return solve(l,m);
}

int main()
{
	scanf("%d%I64d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%I64d",a+i);
		if(a[i]>MAX) MAX=a[i];
		SUM=SUM+a[i];
	}
	if(k>SUM) printf("-1\n");
	else if(MAX==1) printf("1\n");
	else printf("%I64d\n",solve(1,MAX));

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
const int MAXA=10000000;
int s[MAXN+10],n,k;
int f[MAXA+10];
bool judge(int le){
	LL cnt=0;
	memset(f,0,sizeof f);
	f[le]=1;
	for(int i=le+1;i<=MAXA;++i)
        f[i]=max(f[i-1],f[i/2]+f[i-i/2]);
	for(int i=1;i<=n;++i)
        cnt+=f[s[i]];
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	LL sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=10000001;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
const int MAXA=10000000;
int s[MAXN+10],n,k;
int f[MAXA+10];
bool judge(int le){
	LL cnt=0;
	memset(f,0,sizeof f);
	f[le]=1;
	for(int i=le+1;i<=MAXA;++i)
        f[i]=max(1,f[i/2]+f[i-i/2]);
	for(int i=1;i<=n;++i)
        cnt+=f[s[i]];
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	LL sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=10000001;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
const int MAXA=10000000;
int s[MAXN+10],n,k;
int f[MAXA+10];
bool judge(int le){
	int cnt=0;
	memset(f,0,sizeof f);
	f[le]=1;
	for(int i=le+1;i<=MAXA;++i)
        f[i]=max(1,f[i/2]+f[i-i/2]);
	for(int i=1;i<=n;++i)
        cnt+=f[s[i]];
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	LL sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=10000001;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
int s[MAXN+10],n,k;
bool judge(int le){
	int cnt=0;
	for(int i=1;i<=n;++i){
		int tmp=s[i]/le,k=1;
		if(tmp==0)continue;
		while(tmp>1)k<<=1,tmp>>=1;
		cnt+=k;
	}
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	int sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=INF;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
const int MAXA=10000000;
int s[MAXN+10],n,k;
int f[MAXA+10];
bool judge(int le){
	int cnt=0;
	memset(f,0,sizeof f);
	f[le]=1;
	for(int i=le+1;i<=MAXA;++i)
        f[i]=max(f[i-1],f[i/2]+f[i-i/2]);
	for(int i=1;i<=n;++i)
        cnt+=f[s[i]];
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	LL sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=10000000;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
const int MAXA=10000000;
int s[MAXN+10],n,k;
int f[MAXA+10];
bool judge(int le){
	int cnt=0;
	memset(f,0,sizeof f);
	f[le]=1;
	for(int i=le+1;i<=MAXA;++i)
        f[i]=max(f[i-1],f[i/2]+f[i-i/2]);
	for(int i=1;i<=n;++i)
        cnt+=f[s[i]];
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	LL sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=10000001;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#include<ctime>
typedef long long int LL;
typedef unsigned long long ULL;
const int INF=0x3f3f3f3f;
const LL INFLL=0x3f3f3f3f3f3f3f3fll;
LL getint(){
    LL ret=0;bool f=0;char c;
    while((c=getchar())<'0'||c>'9')if(c=='-')f=!f;
    while(c>='0'&&c<='9'){ret=ret*10+c-'0';c=getchar();}
    return f?-ret:ret;
}
using namespace std;
const int MAXN=1000000;
int s[MAXN+10],n,k;
bool judge(int le){
	int cnt=0;
	for(int i=1;i<=n;++i){
		int tmp=s[i]/le,k=1;
		if(tmp==0)continue;
		while(tmp>1)k<<=1,tmp>>=1;
		cnt+=k;
	}
	return cnt>=k;
}
int main(){
	n=getint(),k=getint();
	LL sum=0;
	for(int i=1;i<=n;++i)
		sum+=s[i]=getint();
	if(sum<k){
		printf("-1\n");
		return 0;
	}
	int l=1,r=2100000000;
	while(l<r){
		int mid=((l+r)>>1)+1;
		if(judge(mid))
			l=mid;
		else
			r=mid-1;
	}
	printf("%d\n",l);
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int n,k,a[1000005],dp[10000007];

bool ok(long long x)
{
    for(long long i = 1;i < x && i <= 10000000;i++)    dp[i] = 0;
    for(long long i = x;i < 2*x && i <= 10000000;i++)  dp[i] = 1;
    for(long long i = 2*x;i <= 10000000;i++)
        dp[i] = dp[i/2]+dp[i/2+i%2];
    int t = k;
    for(int i = 1;i <= n;i++)
    {
        t -= dp[a[i]];
        if(t <= 0)  return 1;
    }
    return 0;
}

int main()
{
    scanf("%d%d",&n,&k);
    long long sum = 0;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(sum < k)
    {
        printf("-1\n");
        return 0;
    }
    long long l = 1,r = sum/k;
    while(l < r)
    {
        long long mid = (l+r+1)/2;
        if(ok(mid)) l = mid;
        else    r = mid-1;
    }
    printf("%I64d\n",l);
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int n,k,a[1000005],dp[10000007];

bool ok(int x)
{
    for(int i = 1;i < x;i++)    dp[i] = 0;
    for(int i = x;i < 2*x;i++)  dp[i] = 1;
    for(int i = 2*x;i <= 10000000;i++)
        dp[i] = dp[i/2]+dp[i/2+i%2];
    int t = k;
    for(int i = 1;i <= n;i++)
    {
        t -= dp[a[i]];
        if(t <= 0)  return 1;
    }
    return 0;
}

int main()
{
    scanf("%d%d",&n,&k);
    int sum = 0;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(sum < k)
    {
        printf("-1\n");
        return 0;
    }
    int l = 1,r = sum/k;
    while(l < r)
    {
        int mid = (l+r+1)/2;
        if(ok(mid)) l = mid;
        else    r = mid-1;
    }
    printf("%d\n",l);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll pp[maxn], dd[maxn];
bool judge(ll m){

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int l = 0, r = 0;
		pp[0] = num[i];
		dd[0] = 1;
		while(1){
			if(pp[l] >= m * 2){
			     int h1 = pp[l] / 2, h2, sign1 = 0, sign2 = 0;
				 h2 = h1;
				 if(pp[l]&1)
				  h1++;
				 for(int j = l+1; j <= r; j++){
				 	if(h1 == pp[l]){
				 		sign1 = 1;
				 		dd[j] += dd[l];
				 	}
				 	if(h2 == pp[l]){
				 		sign2 = 1;
				 		dd[j] += dd[l];
				 	}

				 }
				 if(sign1 == 0){
				 	pp[++r] = h1;
				 	dd[r] = dd[l];
				 }
				 if(sign2 == 0){
				 	pp[++r] = h2;
				 	dd[r] = dd[l];
				 }
			}
			else
			  break;
			l++;
		}
		for(int j = l; j <= r; j++)
		 ans += dd[j];
	}
	if(ans >= k)
	 return true;
	return false;
}
int get_int(){
	int ss = 0;
	char ch = getchar();
	while(ch >= '0' && ch <= '9'){
		ss = ss * 10 + ch - '0';
		ch = getchar();
	}
	return ss;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	n = get_int();
	k = get_int();
	for(int i = 0; i < n; i++){
	 num[i] = get_int();
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e7+1;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll pp[maxn], dd[maxn];
bool judge(ll m){

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int l = 0, r = 0;
		pp[0] = num[i];
		dd[0] = 1;
		while(1){
			if(pp[l] >= m * 2){
			     int h1 = pp[l] / 2, h2, sign1 = 0, sign2 = 0;
				 h2 = h1;
				 if(pp[l]&1)
				  h1++;
				 for(int j = l+1; j <= r; j++){
				 	if(h1 == pp[j]){
				 		sign1 = 1;
				 		dd[j] += dd[l];
				 	}
				 	if(h2 == pp[j]){
				 		sign2 = 1;
				 		dd[j] += dd[l];
				 	}

				 }
				 if(sign1 == 0){
				 	pp[++r] = h1;
				 	dd[r] = dd[l];
				 }
				 if(sign2 == 0){
				 	pp[++r] = h2;
				 	dd[r] = dd[l];
				 }
			}
			else
			  break;
			l++;
		}
		for(int j = l; j <= r; j++)
		 ans += dd[j];
	}
	if(ans >= k)
	 return true;
	return false;
}
int get_int(){
	int ss = 0;
	char ch = getchar();
	while(ch >= '0' && ch <= '9'){
		ss = ss * 10 + ch - '0';
		ch = getchar();
	}
	return ss;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	n = get_int();
	k = get_int();
	for(int i = 0; i < n; i++){
	 num[i] = get_int();
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e7+1;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll pp[maxn], dd[maxn];
bool judge(ll m){

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int l = 0, r = 0;
		pp[0] = num[i];
		dd[0] = 1;
		while(1){
			if(pp[l] >= m * 2){
			      int h = pp[l] / 2, sign = 0;
			      if(pp[l]&1)
			       h++;
			      for(int j = l+1; j <= r; j++){
			       if(h == pp[j]){
			       	sign = 1;
			        dd[j] += dd[l];
			        break;
			        }
			       }
			      if(sign == 0){
			       pp[++r] = h;
			       dd[r] = dd[l];
			      }
			      h = pp[l] / 2;
			      sign = 0;
			     for(int j = l+1; j <= r; j++){
			     	if(h == pp[j]){
			     	 dd[j] += dd[l];
			     	 sign = 1;
			        }
			     }
			     if(sign == 0){
			       pp[++r] = h;
			       dd[r] = dd[l];
			      }
			}
			else
			  break;
			l++;
		}
		for(int j = l; j <= r; j++)
		 ans += dd[j];
	}
	if(ans >= k)
	 return true;
	return false;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
	 scanf("%d", num+i);
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e7+1;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll dd[10000005];
bool judge(ll m){

	ll ans = 0;
	memset(dd, 0, sizeof(dd));
	for(int i = 0; i < n; i++)
	 dd[num[i]]++;
	for(int i = 1e7; i >= 0; i--){
		if(dd[i] == 0)
		 continue;
		if(i >= 2 * m){
			dd[i/2] += dd[i];
			if(i&1)
			 dd[i/2+1] += dd[i];
			else
			 dd[i/2] += dd[i];
		}
		else if(i < m)
		       break;
		else{
		 ans += dd[i];
	    }
	}
	if(ans >= k)
	 return true;
	return false;
}
int get_int(){
	int ss = 0;
	char ch = getchar();
	while(ch >= '0' && ch <= '9'){
		ss = ss * 10 + ch - '0';
		ch = getchar();
	}
	return ss;
}
int main(){

	//freopen("in.txt", "r", stdin);
	ll sum = 0;
	n = get_int();
	k = get_int();
	for(int i = 0; i < n; i++){
	 num[i] = get_int();
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e7+1;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
map<int, int> v;
bool judge(ll m){

	map<int, int> ::iterator iter;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int d = 0;
		v.clear();
		v[num[i]]++;
		while(1){
			iter = --v.end();
			int h1 = iter -> first;
			int h2 = iter -> second;
			if(h1 >= 2 * m){
				v.erase(iter);
				v[h1/2] += h2;
				if(h1&1)
				 v[h1/2+1] += h2;
				else
				 v[h1/2] += h2;
			}
			else
			 break;
		}
		iter = v.begin();
		while(iter != v.end()){
			ans += iter -> second;
			iter++;
		}
	}
	if(ans >= k)
	 return true;
	return false;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
	 scanf("%d", num+i);
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e9;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll pp[maxn], dd[maxn];
bool judge(ll m){

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int l = 0, r = 0;
		pp[0] = num[i];
		dd[0] = 1;
		while(1){
			if(pp[l] >= m * 2){
			      int h = pp[l] / 2, sign = 0;
			      if(pp[l]&1)
			       h++;
			      for(int j = l+1; j <= r; j++){
			       if(h == pp[j]){
			       	sign = 1;
			        dd[j] += dd[l];
			        break;
			        }
			       }
			      if(sign == 0){
			       pp[++r] = h;
			       dd[r] = dd[l];
			      }
			      h = pp[l] / 2;
			      sign = 0;
			     for(int j = l+1; j <= r; j++){
			     	if(h == pp[j]){
			     	 dd[j] += dd[l];
			     	 sign = 1;
			        }
			     }
			     if(sign == 0){
			       pp[++r] = h;
			       dd[r] = dd[l];
			      }
			}
			else
			  break;
			l++;
		}
		for(int j = l; j <= r; j++)
		 ans += dd[j];
	}
	if(ans >= k)
	 return true;
	return false;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
	 scanf("%d", num+i);
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e9;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll pp[maxn], dd[maxn];
bool judge(ll m){

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int l = 0, r = 0;
		pp[0] = num[i];
		dd[0] = 1;
		while(1){
			if(pp[l] >= m * 2){
			     int h1 = pp[l] / 2, h2, sign1 = 0, sign2 = 0;
				 h2 = h1;
				 if(pp[l]&1)
				  h1++;
				 for(int j = l+1; j <= r; j++){
				 	if(h1 == pp[j]){
				 		sign1 = 1;
				 		dd[j] += dd[l];
				 	}
				 	if(h2 == pp[j]){
				 		sign2 = 1;
				 		dd[j] += dd[l];
				 	}

				 }
				 if(sign1 == 0){
				 	pp[++r] = h1;
				 	dd[r] = dd[l];
				 	if(h1 == h2){
				 		dd[r] += dd[l];
				 		sign2 = 1;
				 	}
				 }
				 if(sign2 == 0){
				 	pp[++r] = h2;
				 	dd[r] = dd[l];
				 }
			}
			else
			  break;
			l++;
		}
		for(int j = l; j <= r; j++)
		 ans += dd[j];
	}
	if(ans >= k)
	 return true;
	return false;
}
int get_int(){
	int ss = 0;
	char ch = getchar();
	while(ch >= '0' && ch <= '9'){
		ss = ss * 10 + ch - '0';
		ch = getchar();
	}
	return ss;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	n = get_int();
	k = get_int();
	for(int i = 0; i < n; i++){
	 num[i] = get_int();
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e7+1;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#define maxn 1000005
#define INF 1000000009
typedef long long ll;
using namespace std;

int num[maxn], n, k;
ll pp[maxn], dd[maxn];
bool judge(ll m){

	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(num[i] < m)
		 continue;
		int l = 0, r = 0;
		pp[0] = num[i];
		dd[0] = 1;
		while(1){
			if(pp[l] >= m * 2){
			      int h = pp[l] / 2, sign = 0;
			      if(pp[l]&1)
			       h++;
			      for(int j = l+1; j <= r; j++){
			       if(h == pp[j]){
			       	sign = 1;
			        dd[j] += dd[l];
			        break;
			        }
			       }
			      if(sign == 0){
			       pp[++r] = h;
			       dd[r] = dd[l];
			      }
			      h = pp[l] / 2;
			      sign = 0;
			     for(int j = l+1; j <= r; j++){
			     	if(h == pp[j]){
			     	 dd[j] += dd[l];
			     	 sign = 1;
			        }
			     }
			     if(sign == 0){
			       pp[++r] = h;
			       dd[r] = dd[l];
			      }
			}
			else
			  break;
			l++;
		}
		for(int j = l; j <= r; j++)
		 ans += dd[j];
	}
	if(ans >= k)
	 return true;
	return false;
}
int get_int(){
	int ss = 0;
	char ch = getchar();
	while(ch >= '0' && ch <= '9'){
		ss = ss * 10 + ch - '0';
		ch = getchar();
	}
	return ss;
}
int main(){

//	freopen("in.txt", "r", stdin);
	ll sum = 0;
	n = get_int();
	k = get_int();
	for(int i = 0; i < n; i++){
	 num[i] = get_int();
	 sum += num[i];
    }
    if(sum < k){
    	puts("-1");
    	return 0;
    }
    ll l = 1, r = 1e7+1;
    while(l < r){
    	ll mid = (l + r) >> 1;
    	if(judge(mid))
    	 l = mid + 1;
    	else
    	 r = mid;
    }
    printf("%I64d\n", l - 1);
	return 0;
}


#include<bits\stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
ll a[maxn];
ll n,k;
bool check(ll p)
{
	ll res=0;
	for(ll i=0;i<n;i++)
	{
		res+=a[i]/p;
	}
	if(res>=k) return true;
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	ll s=0;
	for(ll i=0;i<n;i++)
		cin>>a[i],s+=a[i];
	if(s<k)
	{
		cout<<"-1\n";
		return 0;
	}
	ll l=1,r=1e18;
	while(l<r)
	{
		ll mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	if(!check(1)) cout<<"-1\n";
	else cout<<l<<'\n';
	return 0;
}


#include<bits\stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
const int maxv=1e7+7;
int a[maxn];
int n,k;
ll cut(int from,int to)
{
	if(from<to) return 0;
	ll cnt0=1,cnt1=0;		//cnt0 is the number of 'from'
	// it is known that 'from' is no more than the other.
	while(from/2>=to)
	{
		if(from%2)	cnt1=cnt1*2+cnt0;
		else cnt0=cnt0*2+cnt1;
		from/=2;
	}
	if((from-from/2)>=to)
	{
		cnt1*=2;
	}
	return cnt0+cnt1;
}
ll check(int p)
{
	ll res=0;
	for(int i=0;i<n;i++)
	{
		res+=cut(a[i],p);
		if(res>=k)	return true;
	}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(ll i=0;i<n;i++)
		cin>>a[i];
	int l=1,r=1e7+7;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	if(!check(1)) cout<<"-1\n";
	else cout<<l<<'\n';
	return 0;
}


#include<bits\stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
ll a[maxn];
ll n,k;
ll cut(ll from,ll to)
{
	ll res=0,ini=from;
	while(from>=to)
	{
		from/=2;
		res++;
	}
	if(res==0) return 0;
	return 1<<(res-1);
}
bool check(ll p)
{
	ll res=0;
	for(ll i=0;i<n;i++)
	{
		res+=cut(a[i],p);
	}
	if(res>=k) return true;
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	ll s=0;
	for(ll i=0;i<n;i++)
		cin>>a[i],s+=a[i];
	if(s<k)
	{
		cout<<"-1\n";
		return 0;
	}
	ll l=1,r=1e7+7;
	while(l<r)
	{
		ll mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	if(!check(1)) cout<<"-1\n";
	else cout<<l<<'\n';
	return 0;
}


#include<bits\stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
const int maxv=1e7+7;
int a[maxn];
int n,k;
ll cut(int from,int to)
{
	if(from<to) return 0;
	ll cnt0=1,cnt1=0;		//cnt0 is the number of 'from'
	// it is known that 'from' is no more than the other.
	while(from/2>=to)
	{
		if(from%2)	cnt1=cnt1*2+cnt0;
		else cnt0=cnt0*2+cnt1;
		from/=2;
	}
	if((from-from/2)>=to)
	{
		cnt1*=2;
	}
	return cnt0+cnt1;
}
ll check(int p)
{
	ll res=0;
	for(int i=0;i<n;i++)
	{
		res+=cut(a[i],p);
		if(res>=k)	return true;
	}
	return false;
}
int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
		scanf("%d",&a[i]);
	int l=1,r=1e7+7;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	if(!check(1)) puts("1");
	else printf("%d\n",l);
	return 0;
}


process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let t = 0; t < N; ++t) {
    const b = readline();
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort((i, j) => i - j);

    let isYes = true;
    for (let k = 1; k < arr.length; ++k) {
      if (arr[k] - arr[k - 1] > 1) {
        print("NO\n");
        isYes = false;
        break;
      }
    }

    if (isYes) {
      print("YES\n");
    }
  }
}


process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let t = 0; t < N; ++t) {
    const b = readline();
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort();

    let isYes = true;
    for (let k = 1; k < arr.length; ++k) {
      if (arr[k] - arr[k - 1] > 1) {
        print("NO\n");
        isYes = false;
        break;
      }
    }

    if (isYes) {
      print("YES\n");
    }
  }
}


process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let t = 0; t < N; ++t) {
    const b = readline();
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort();

    let isYes = true;
    for (let k = 1; k < arr.length; ++k) {
      if (arr[i] - arr[i - 1] > 1) {
        print("NO");
        isYes = false;
        break;
      }
    }

    if (isYes) {
      print("YES");
    }
  }
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let i = 0; i < N; ++i) {
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort();

    const isYes = arr.every((x, i) => {
      if (i < 1) {
        return true;
      } else if (Math.abs(x - arr[i - 1]) <= 1) {
        return true;
      } else {
        return false;
      }
    });

    if (isYes) {
      print("YES");
    } else {
      print("NO");
    }
  }
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  while (T--) {
    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)

    let result = 'YES'

    a.sort(cmpi)

    for (let i = 1; i < a.length; i++) {
      if (a[i] - a[i-1] > 1) {
        result = 'NO'
        break
      }
    }

    out += result + '\n'
  }

  console.log(out)
}


process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let t = 0; t < N; ++t) {
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort();

    let bool = true;
    for (let k = 1; k < arr.length; ++k) {
      if (x - arr[i - 1] > 1) {
        print("NO");
        bool = false;
        break;
      }
    }

    if (bool) {
      print("YES");
    }
  }
}


process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let t = 0; t < N; ++t) {
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort();

    const isYes = arr.every((x, i) => {
      if (i < 1) {
        return true;
      } else if (Math.abs(x - arr[i - 1]) <= 1) {
        return true;
      } else {
        return false;
      }
    });

    if (isYes) {
      print("YES");
    } else {
      print("NO");
    }
  }
}


process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const N = readline();

  for (let t = 0; t < N; ++t) {
    const b = readline();
    const arr = readline()
      .split(" ")
      .map((x) => parseInt(x));

    arr.sort();

    let isYes = true;
    for (let k = 1; k < arr.length; ++k) {
      if (arr[k] - arr[k - 1] > 1) {
        print("NO");
        isYes = false;
        break;
      }
    }

    if (isYes) {
      print("YES");
    }
  }
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main(){
    let t = parseInt(readline());
    for(let i = 0; i < t; i++){
        let n = parseInt(readline());
        let arr = readline().split(' ');
        arr.sort((a,b) => a-b);
        let flag = true;
        for(let j = 1; j < arr.length; j++){
            if(parseInt(arr[j])-parseInt(arr[j-1]) > 1){
                flag = false;
                console.log('NO');
                break;
            }
        }

        if(flag)
            console.log('yes');
    }
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
5
3
1 2 2
4
5 5 5 5
3
1 2 4
4
1 3 4 4
1
100
**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve(r);
    }

}

function solve(index) {
    let n = Number(readline());
    let a = readline().split(" ").map(Number);

    a.sort((x, y) => x - y);
    if(a.length === 1) {
        console.log('YES');
        return;
    }

    for(let i=1;i<a.length;i++) {
        if(Math.abs(a[i] - a[i-1]) > 1) {
            console.log('NO');
            return;
        }
    }

    console.log('YES');

}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
5
3
1 2 2
4
5 5 5 5
3
1 2 4
4
1 3 4 4
1
100
**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve(r);
    }

}

function solve(index) {
    let n = Number(readline());
    let a = readline().split(" ").map(Number);

    if(a.length === 1) {
        console.log('YES');
        return;
    }

    for(let i=1;i<a.length;i++) {
        if(Math.abs(a[i] - a[i-1]) > 1) {
            console.log('NO');
            return;
        }
    }

    console.log('YES');

}


using System;
using System.Linq;
using System.Collections.Generic;

namespace firstTask
{

    class Program
    {

        static void Main(string[] args)
        {

            int cases =int.Parse(Console.ReadLine());
            while(cases -- >=0)
            {
                int n =int.Parse(Console.ReadLine());
                int []arr = new int[n];
                for(int i =0 ; i <n ; i ++)
                {
                    arr[i]=int.Parse(Console.ReadLine());
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(arr[i]) ==true) { }
                    else myDict.Add(arr[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

    }

}


using System;
using System.Linq;
using System.Collections.Generic;

#nullable enable

    class Program
    {

        static void Main(string[] args)
        {

            int cases =Convert.ToInt32(Console.ReadLine());
            while(cases -- >=0)
            {
                int n =Convert.ToInt32(Console.ReadLine());
                int []arr = new int[n];
                for(int i =0 ; i <n ; i ++)
                {
                    arr[i]=Convert.ToInt32(Console.ReadLine());
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(arr[i]) ==true) { }
                    else myDict.Add(arr[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

}


using System;
using System.Linq;
using System.Collections.Generic;

    class Program
    {

        static void Main(string[] args)
        {

            int cases =Convert.ToInt32(Console.ReadLine());
            while(cases -- >=0)
            {
                int n =Convert.ToInt32(Console.ReadLine());
                int []arr = new int[n];
                for(int i =0 ; i <n ; i ++)
                {
                    arr[i]=Convert.ToInt32(Console.ReadLine());
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(arr[i]) ==true) { }
                    else myDict.Add(arr[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

}


using System;
using System.Linq;
using System.Collections.Generic;

#nullable enable

namespace firstTask
{

    class Program
    {

        static void Main(string[] args)
        {

            int cases =Convert.ToInt32(Console.ReadLine());
            while(cases -- >=0)
            {
                int n =Convert.ToInt32(Console.ReadLine());
                int []arr = new int[n];
                for(int i =0 ; i <n ; i ++)
                {
                    arr[i]=Convert.ToInt32(Console.ReadLine());
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(arr[i]) ==true) { }
                    else myDict.Add(arr[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

    }

}


using System;
using System.Linq;
using System.Collections.Generic;

#nullable enable

namespace firstTask
{

    class Program
    {

        static void Main(string[] args)
        {

            int cases =int.Parse(Console.ReadLine());
            while(Convert.ToBoolean(cases --))
            {
                int n =int.Parse(Console.ReadLine());
                List<int> myList = new List<int>();
                foreach(var temp in Console.ReadLine().Split())
                {

                    myList.Add(Convert.ToInt32(temp));
                }

                if(n ==1){
                    Console.WriteLine("YES");
                    continue;
                }

                bool hasAnswer1 =true;
                bool hasAnswer2 =true;
                myList.Sort();
                //for(int i =0 ; i <myList.Count ; i ++) Console.WriteLine(myList[i]);

                int x =myList[0];
                for(int i =1 ; i <myList.Count ; i ++){

                    if(x ==myList[i]) { }
                    else if(x +1 ==myList[i]) x ++;
                    else hasAnswer1 =false;

                }

                myList.Reverse();
                x =myList[0];
                for(int i =1 ; i <myList.Count ; i ++){

                    if(x ==myList[i]) { }
                    else if(x -1 ==myList[i]) x ++;
                    else hasAnswer2 =false;

                }

                 if(hasAnswer1 || hasAnswer2) Console.WriteLine("YES");
                 else Console.WriteLine("NO");
                 myList.Clear();

            }

        }

    }

}


using System;
using System.Linq;
using System.Collections.Generic;

#nullable enable

namespace firstTask
{

    class Program
    {

        static void Main(string[] args)
        {

            int cases =int.Parse(Console.ReadLine());
            while(Convert.ToBoolean(cases --))
            {
                int n =int.Parse(Console.ReadLine());
                int []arr = new int[n];
                for(int i =0 ; i <n ; i ++)
                {
                    arr[i]=int.Parse(Console.ReadLine());
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(arr[i]) ==true) { }
                    else myDict.Add(arr[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

    }

}


using System;
using System.Linq;
using System.Collections.Generic;

    class Program
    {

        static void Main(string[] args)
        {

            int cases =int.Parse(Console.ReadLine());
            while(cases -- >=0)
            {
                int n =int.Parse(Console.ReadLine());
                int []arr = new int[n];
                for(int i =0 ; i <n ; i ++)
                {
                    arr[i]=int.Parse(Console.ReadLine());
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(arr[i]) ==true) { }
                    else myDict.Add(arr[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

}


using System;
using System.Linq;
using System.Collections.Generic;

#nullable enable

namespace firstTask
{

    class Program
    {

        static void Main(string[] args)
        {

            int cases =int.Parse(Console.ReadLine());
            while(Convert.ToBoolean(cases --))
            {
                int n =int.Parse(Console.ReadLine());
                List<int> myList = new List<int>();
                foreach(var temp in Console.ReadLine().Split())
                {

                    myList.Add(Convert.ToInt32(temp));
                }
                Dictionary<int , int> myDict = new Dictionary<int, int>();
                for(int i =0 ; i <n ; i ++)
                {

                    if(myDict.ContainsKey(myList[i]) ==true) { }
                    else myDict.Add(myList[i] , i);

                }

                // foreach(var temp in myDict){
                //     Console.WriteLine("{0} and {1} is" , temp.Key , temp.Value);
                // }

                bool hasAnswer =false;

                if(myDict.Count <=2){

                    int ans =0;
                    if(myDict.Count ==2) ans =Math.Abs(myDict.Keys.ElementAt(0) -myDict.Keys.ElementAt(1));

                    if(ans >1) { }
                    else hasAnswer =true;

                }

                 if(hasAnswer) Console.WriteLine("YES");
                 else Console.WriteLine("NO");

                myDict.Clear();

            }

        }

    }

}


using System;
using System.Net;
using System.IO;
using System.Collections.Generic;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            for (int i=0;i<x;i++)
            {
                int n = int.Parse(Console.ReadLine());
                string[] s = Console.ReadLine().Split();
                List<int> nums = new List<int>();
                for(int j=0;j<s.Length;j++)
                {
                    nums.Add(int.Parse(s[j]));
                }
                nums.Sort();
                int kol = 0;
                for (int j = 0; j < nums.Count-1; j++)
                {
                    if (Math.Abs(nums[j]-nums[j+1])>1)
                    {
                        kol++;
                    }
                }
                Console.WriteLine(kol == 0 ? "YES" : "NO");
            }
        }
    }
}


using System;
using System.Collections.Immutable;
using System.Linq;
using System.Net.Sockets;
using System.Security.Authentication;

namespace Remove_Smallest
{
    class Program
    {
        static void Main(string[] args)
        {
            int testCasesNumber = Convert.ToInt32(Console.ReadLine());
            for (int k = 0; k < testCasesNumber; k++)
            {
                var input = Console.ReadLine();
                int n = Convert.ToInt32(input);
                int[] arr = new int[n];
                var flag = 0;
                var volumes = Console.ReadLine().Split(" ");

                for (int r = 0; r < n; r++)
                {
                    arr[r] = Convert.ToInt32(volumes[r]);
                }
                Array.Sort(arr);
                for(int i=1; i<n; i++)
                {
                    if(arr[i] - arr[i-1] > 1)
                    {
                        flag = 1;
                        Console.WriteLine("NO");
                        break;
                    }
                }
                if(flag == 0)
                {
                    Console.WriteLine("YES");
                }
            }
        }
    }
}


using System;
using System.Security.Authentication;

namespace Remove_Smallest
{
    class Program
    {
        static void Main(string[] args)
        {
            int testCasesNumber = Convert.ToInt32(Console.ReadLine());
            for (int k = 0; k < testCasesNumber; k++)
            {
                var input = Console.ReadLine();
                int n = Convert.ToInt32(input);
                int[] arr = new int[n];
                var flag = 0;
                var volumes = Console.ReadLine().Split(" ");

                for (int r = 0; r < n; r++)
                {
                    arr[r] = Convert.ToInt32(volumes[r]);
                }

                for (int i = 0; i < n; i++)
                {
                    for (int j = 1; j < n; j++)
                    {

                        if (Math.Abs(arr[i]-arr[j]) > 1 && n>1)
                        {
                            flag = 1;
                            Console.WriteLine("NO");
                            break;
                        }
                    }
                    break;
                }

                if (flag == 0)
                {
                    Console.WriteLine("YES");

                }

            }
        }
    }
}


using System;
using System.Security.Authentication;

namespace Remove_Smallest
{
    class Program
    {
        static void Main(string[] args)
        {
            int testCasesNumber = Convert.ToInt32(Console.ReadLine());
            for (int k = 0; k < testCasesNumber; k++)
            {
                var input = Console.ReadLine();
                int n = Convert.ToInt32(input);
                int[] arr = new int[n];
                var flag = 0;
                var volumes = Console.ReadLine().Split(" ");

                for (int r = 0; r < n; r++)
                {
                    arr[r] = Convert.ToInt32(volumes[r]);
                }

                for (int i = 0; i < n; i++)
                {
                    for (int j = 1; j < n; j++)
                    {

                        if (Math.Abs(arr[i]-arr[j]) > 1 && n>1)
                        {
                            flag = 1;
                            Console.WriteLine("NO");
                            break;
                        }
                    }
                }

                if (flag == 0)
                {
                    Console.WriteLine("YES");

                }

            }
        }
    }
}


using System;
using System.Collections.Immutable;
using System.Linq;
using System.Net.Sockets;
using System.Security.Authentication;

namespace Remove_Smallest
{
    class Program
    {
        static void Main(string[] args)
        {
            int testCasesNumber = Convert.ToInt32(Console.ReadLine());
            for (int k = 0; k < testCasesNumber; k++)
            {
                var input = Console.ReadLine();
                int n = Convert.ToInt32(input);
                int[] arr = new int[n];
                var flag = 0;
                var volumes = Console.ReadLine().Split(" ");

                for (int r = 0; r < n; r++)
                {
                    arr[r] = Convert.ToInt32(volumes[r]);
                }
                for (int i = 0; i < arr.Length; i++)
                {
                    int min = arr.Min();

                    for (int j = 0; j < arr.Length; j++)
                    {
                        int count = arr.Count(n => n == min);
                        if (arr[j] == min + 1 || count > 1)
                        {
                            arr = arr.Where(f => f != min).ToArray();
                        }
                        else
                        {
                            flag = 1;
                            Console.WriteLine("NO");
                            break;

                        }
                    }
                }

                if(flag == 0)
                {
                    Console.WriteLine("YES");
                }
            }
        }
    }
}

//Array.Sort(arr);
//for (int i = 1; i < n; i++)
//{
//    if (arr[i] - arr[i - 1] > 1)
//    {
//        flag = 1;
//        Console.WriteLine("NO");
//        break;
//    }
//}
//if (flag == 0)
//{
//    Console.WriteLine("YES");
//}


using System;

class MainClass {
  public static void Main (string[] args) {
    int t = int.Parse(Console.ReadLine());
    for(int _ = 0; _ < t; _++){
    int n = int.Parse(Console.ReadLine());
    string[] s = Console.ReadLine().Split(' ');
    int[] a = Array.ConvertAll(s,int.Parse);
    Array.Sort(a);
    bool possible = true;
    int i = 1;
    while(possible && i < n){
      possible = (Math.Abs(a[i-1] - a[i]) <= 1);
      i++;
    }
    if(possible){
      Console.WriteLine("YES");
    }else{
      Console.WriteLine("NO");
    }
  }
    }

}


using System;

class MainClass {
  public static void Main (string[] args) {
    int t = int.Parse(Console.ReadLine());
    for (int _ = 0; _ < t; _++){
      int n = int.Parse(Console.ReadLine());
      string[] s = Console.ReadLine().Split(' ');
      bool final = true;
      int[] a = Array.ConvertAll(s, int.Parse);
      for(int i = 0; i < a.Length; i++){
        bool res = false;
        for(int j = 0; j < a.Length; j++){
          if( i != j && Math.Abs(a[i]-a[j]) <= 1){
            res = true;
            break;
          }
        }
        final = res;
        if(res == false){
          break;
        }
      }
      if(a.Length == 1){
        Console.WriteLine(true);
      }else{
        Console.WriteLine(final);
      }

    }

  }
}


using System;

class MainClass {
  public static void Main (string[] args) {
    int t = int.Parse(Console.ReadLine());
    for (int _ = 0; _ < t; _++){
      int n = int.Parse(Console.ReadLine());
      string[] s = Console.ReadLine().Split(' ');
      bool final = true;
      int[] a = Array.ConvertAll(s, int.Parse);
      for(int i = 0; i < a.Length; i++){
        bool res = false;
        for(int j = 0; j < a.Length; j++){
          if( i != j && Math.Abs(a[i]-a[j]) <= 1){
            res = true;
            break;
          }
        }
        final = res;
        if(res == false){
          break;
        }
      }
      if(a.Length == 1 || final == true){
        Console.WriteLine("YES");
      }else{
        Console.WriteLine("NO");
      }

    }

  }
}


using System;
using System.Linq;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i < t; i++)
            {
                int n = Convert.ToInt32(Console.ReadLine());
                int[] arr = new int[n];
                for (int j = 0; j < n; j++)
                    arr[j] = Convert.ToInt32(Console.ReadLine());
                Array.Sort(arr);
                int f = 0;
                for(int j = 0; j < n-1; j++)
                {
                    int k = j + 1;
                    if (arr[j] - arr[k] > 1)
                    {
                        f = 1;
                        break;
                    }
                }
                if (f == 1)
                    Console.WriteLine("NO");
                else
                    Console.WriteLine("YES");
            }

        }
    }
}


using System;
using System.Linq;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i < t; i++)
            {
                int n = Convert.ToInt32(Console.ReadLine());
                int[] arr = new int[n];

                    string s1 = Console.ReadLine();
                string[] sar = s1.Split(" ");
                for(int j = 0; j < n; j++)
                {
                    arr[j] = Convert.ToInt32(sar[j]);
                }
                Array.Sort(arr);
                int f = 0;
                for (int j = 0; j < n - 1; j++)
                {
                    int k = j + 1;
                    if (arr[k] - arr[j] > 1)
                    {
                        f = 1;
                        break;
                    }
                }
                if (f == 1)
                    Console.WriteLine("NO");
                else
                    Console.WriteLine("YES");
            }

        }
    }
}


using System;
using System.Linq;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i < t; i++)
            {
                int n = Convert.ToInt32(Console.ReadLine());
                int[] arr = new int[n];

                    string s1 = Console.ReadLine();
                string[] sar = s1.Split(" ");
                for(int j = 0; j < n; j++)
                {
                    arr[j] = Convert.ToInt32(sar[j]);
                }
                Array.Sort(arr);
                int f = 0;
                for(int j = 0; j < n-1; j++)
                {
                    int k = j + 1;
                    if (arr[j] - arr[k] > 1)
                    {
                        f = 1;
                        break;
                    }
                }
                if (f == 1)
                    Console.WriteLine("NO");
                else
                    Console.WriteLine("YES");
            }

        }
    }
}