//dp[i]表示以2^i结尾的子序列个数
//枚举a[k]做为结尾的情况即可
#include <iostream>
#include <cstring>
using namespace std;
const int N=1e5+20;
typedef long long ll;
const ll mod=1e9+7;
int a[N];
int dp[35];//dp[i]表示以2^i结尾的子序列个数
//枚举a[k]做为2^i结尾的情况即可
int main()
{
int t;
cin>>t;
while(t--)
{
memset(dp,0,sizeof(dp));
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
ll ans=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=30;j++)
{
//枚举顺序2^(j-1)结尾的子序列都在2^j前面
if(a[i]==(1<<j))
{
if(j)
dp[j]=(dp[j]+dp[j-1])%mod;
else
dp[j]++;
break;
}
}
}
for(int j=0;j<=30;j++)
{
ans=(ans+dp[j])%mod;
}
cout<<ans<<endl;
}
return 0;
}