#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int> >
#define mii map<int,int>
#define ll long long 
#define int long long
#define double long double
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)
 
using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
int mpow(int x,int y,int m)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%m;
		y=y>>1;
		x=x*x%m;
	}
	return res;
}
int ncr(int n,int r)
{
	if(r>n)
	return 0;
	int res=1;
	loop(i,1,r+1)
	res=res*(n-r+i)/i;
	return res;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}


/***************************************************************************************************************************************************************/

void solve()	
{
	int n;
	cin>>n;
	int x[n];
	loop(i,0,n)
	cin>>x[i];
	int cnt[60];
	mem(cnt,0);
	loop(i,0,n)
	{
		int temp=x[i];
		loop(j,0,60)
		{
			cnt[j]+=(temp&1);
			temp>>=1;
		}
	}
	int total[119];
	mem(total,0);
	loop(i,0,n)
	{
		int left[60],right[60];
		mem(left,0);mem(right,0);
		loop(j,0,60)
		{
			right[j]=cnt[j];
			if((x[i]&1LL<<j)==0)
			continue;
			left[j]=cnt[j];
			right[j]=n;
		}
		loop(j,0,60)
		{
			if(left[j]==0)
			continue;
			loop(k,0,60)
			{
				total[j+k]+=left[j]*right[k];
			}
		}
		//loop(j,0,60)
		//cout<<left[j]<<" ";
		//cout<<"\n";
		//loop(j,0,60)
		//cout<<right[j]<<" ";
		//cout<<"\n";
		
	}
	
	int ans=0;
	loop(i,0,119)
	{
		//cout<<total[i]<<" ";
		total[i]%=mod2;
		ans+=mpow(2,i,mod2)*total[i]%mod2;
	}
	cout<<ans%mod2;
}


signed main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	cin>>t;
	loop(i,1,t+1)
	{
		//cout<<"Case #"<<i<<": ";
		solve();
		cout<<"\n";
	}
}


