#include<cstdio>
#include<algorithm>
#include<cstring>
 
using namespace std;
 
const long long mod=1000000007;
 
int n,po,l,r,mid,ans1,ans2;
long long d[201],K,ma,k,a[201],mi,ans,tot,f[61][61][2],ff[61][61][2],t[61],tmp,len,m,mii[201][24401],le;
 
struct node
{
	long long b,c,d;
	int po;
}x[201];
 
int solve(long long ll,long long r)
{
	if (ll==0) return 0;
	if (ll==1) return 1;
	t[0]=0; ll--;
	while (ll) t[++t[0]]=ll%2,ll/=2; len=t[0];
	for (int i=1; i<=(t[0]/2); i++) tmp=t[i],t[i]=t[t[0]-i+1],t[t[0]-i+1]=tmp;
	memset(f,0,sizeof(f));
	f[0][0][1]=1;
	for (int i=1; i<=t[0]; i++)
		for (int l=0; l<=60; l++)
			for (int j=0; j<=1&&j+l<=60; j++)
				if (j>t[i])
					f[i][l+j][0]+=f[i-1][l][0];
				else
				if (j<t[i])
					f[i][l+j][0]+=f[i-1][l][0]+f[i-1][l][1];
				else
					f[i][l+j][0]+=f[i-1][l][0],f[i][l+j][1]+=f[i-1][l][1];
	t[0]=0;
	while (r) t[++t[0]]=r%2,r/=2;
	for (int i=1; i<=(t[0]/2); i++) tmp=t[i],t[i]=t[t[0]-i+1],t[t[0]-i+1]=tmp;
	memset(ff,0,sizeof(ff));
	ff[0][0][1]=1;
	for (int i=1; i<=t[0]; i++)
		for (int l=0; l<=60; l++)
			for (int j=0; j<=1&&j+l<=60; j++)
				if (j>t[i])
					ff[i][l+j][0]+=ff[i-1][l][0];
				else
				if (j<t[i])
					ff[i][l+j][0]+=ff[i-1][l][0]+ff[i-1][l][1];
				else 
					ff[i][l+j][0]+=ff[i-1][l][0],ff[i][j+l][1]+=ff[i-1][l][1];
	for (int i=1; i<=60; i++)
		if (f[len][i][0]+f[len][i][1]!=ff[t[0]][i][0]+ff[t[0]][i][1]) return i;
}
 
bool cmp(node a,node b) {return a.c<b.c;}

int main()
{
	//freopen("f.in","r",stdin);
	scanf("%d%lld",&n,&K); ma=0;
	for (int i=1; i<=n; i++) {scanf("%lld",&a[i]); if (a[i]>ma) ma=a[i];}
	ma*=2ll;
	sort(a+1,a+1+n);
	x[0].c=-1; tot=0; 
	memset(mii,0,sizeof(mii));
	for (k=1; K>=0&&k<=ma; k*=2ll,K--)
	{
		mi=(2e18);
		for (int i=1; i<=n; i++) 
		{
			x[i].c=a[i]%k; x[i].b=a[i]/k; x[i].d=x[i].b; x[i].po=i;
			if (x[i].b<mi) mi=x[i].b;
		}
		sort(x+1,x+n+1,cmp);
		//printf("%d\n",x[2].d);
		for (int i=1; i<=n; i++)
		{
			if (mi<0) break;
			if (x[i].c!=x[i-1].c)
			{
				ans=solve(x[i-1].c+1,x[i].c);
				if (ans>K) {if (x[i].b-1<mi) mi=x[i].b-1; x[i].d--; continue;}
				//printf("%lld %lld %lld\n",c[i-1]+1,x[i].c,ans);
				po=1;
				for (int j=1; j<=n; j++) d[x[j].po]=x[j].d;
				//if (d[1]==1&&d[2]==2&&d[3]==4) {printf("%lld %lld %lld %lld\n",K,ans,x[i-1].c+1,x[i].c);}
				for (int j=2; j<=n; j++)
					if (d[j]!=d[j-1]) 
					{
						if (d[j]>d[j-1]+1) {po=0; break;}
						if (po==1) po=j;
						else {po=0; break;}
					}
			//	printf("#####\n");
			//	printf("%d %lld %lld %lld\n",i,K,x[i-1].c+1,x[i].c);
			//	printf("*****\n");
			//	for (int j=1; j<=n; j++) printf("%d ",d[j]); printf("\n");
			//	printf("*****\n");
				if (!po)
				{
					if (K-ans>mi) tot=(tot+mi+1)%mod;
					else tot=(tot+K-ans+1)%mod;
				} else
				{
					//printf("%lld %lld %lld %lld\n",K,ans,mi,tot);
				//	printf("%lld\n",tot);
					if (k>ma) printf("%d\n",po);
					if (K-ans>mi) m=mi; else m=K-ans;
					l=1; r=mii[po][0]; ans1=0; le=d[1]-m; if (le<0) le=0;
			//		printf("%d %d\n",po,mii[po][0]);
			//		for (int j=1; j<=mii[po][0]; j++) printf("%d ",mii[po][j]); printf("\n");
			//		printf("%d %d\n",le,d[1]);
					while (l<=r)
					{
						mid=(l+r)>>1;
						if (mii[po][mid]<le) ans1=mid,l=mid+1; else r=mid-1;
					}
					l=1; r=mii[po][0]; ans2=0;
					while (l<=r)
					{
						mid=(l+r)>>1;
						if (mii[po][mid]<=d[1]) ans2=mid,l=mid+1; else r=mid-1;
					}
					if (ans1==ans2)
					{
						if (!(ans1&1)) 
						{
							tot=(tot+d[1]-le+1)%mod;
							mii[po][0]+=2;
							for (int j=mii[po][0]; j>ans1+2; j--) mii[po][j]=mii[po][j-2];
							mii[po][ans1+2]=d[1]; mii[po][ans1+1]=le;
						}
					} else
					{
						if (ans1&1)
						{
							if (ans2&1)
							{
								for (int j=ans1+1; j<ans2; j+=2) tot=(tot+mii[po][j+1]-mii[po][j]-1)%mod;
								mii[po][0]-=ans2-ans1;
								for (int j=ans1+1; j<=mii[po][0]; j++) mii[po][j]=mii[po][j+ans2-ans1];
							} else
							{
								for (int j=ans1+1; j<ans2; j+=2) tot=(tot+mii[po][j+1]-mii[po][j]-1)%mod;
								tot=(tot+d[1]-mii[po][ans2])%mod;
								mii[po][0]-=ans2-ans1-1; mii[po][ans1+1]=d[1];
								for (int j=ans1+2; j<=mii[po][0]; j++) mii[po][j]=mii[po][j+ans2-ans1-1];
							}
						} else
						{
							if (ans2&1)
							{
								tot=(tot+mii[po][ans1+1]-le)%mod;
								for (int j=ans1+2; j<ans2; j+=2) tot=(tot+mii[po][j+1]-mii[po][j]-1)%mod;
								mii[po][0]-=ans2-ans1-1; mii[po][ans1+1]=le;
								for (int j=ans1+2; j<=mii[po][0]; j++) mii[po][j]=mii[po][j+ans2-ans1-1];
							} else
							{
								tot=(tot+mii[po][ans1+1]-le)%mod; tot=(tot+d[1]-mii[po][ans2])%mod;
								for (int j=ans1+2; j<ans2; j+=2) tot=(tot+mii[po][j+1]-mii[po][j]-1)%mod;
								mii[po][0]-=ans2-ans1-2; mii[po][ans1+1]=le; mii[po][ans1+2]=d[1];
								for (int j=ans1+3; j<=mii[po][0]; j++) mii[po][j]=mii[po][j+ans2-ans1-2];
							}
						}
					}
			//		printf("%lld\n",tot);
			//		printf("---------\n");
					//printf("%lld %lld %lld %lld\n",k,d[1],m,mii[po]);
					/*if (x[1].d-m<mii[po]) 
					{
						//printf("%lld %lld\n",mii[po],x[1].d);
						if (mii[po]>x[1].d) tot=(tot+m+1)%mod; else tot=(tot+mii[po]-x[1].d+m)%mod;
						//printf("%lld %lld %lld %lld %d\n",x[1].d,m,tot,mii[po],po);
						mii[po]=x[1].d-m;
					}*/
				}
				//printf("%lld %lld\n",x[i-1].c+1,x[i].c);
				//for (int j=1; j<=n; j++) printf("%lld %lld %lld %lld %lld\n",x[j].d,K,ans,mi,tot); printf("\n");
			}
			//if (i==2) printf("%d\n",x[i].d);
			if (x[i].b-1<mi) mi=x[i].b-1; x[i].d--;
		}
	}
	/*for (int i=1; i<=n; i++)
	{
		printf("---------\n");
		printf("%d\n",mii[i][0]);
		for (int j=1; j<=mii[i][0]; j++) printf("%d ",mii[i][j]); printf("\n");
	}*/
	printf("%lld\n",tot);
	return 0;
}

Measured memory_bytes: 38656