Problem: Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k. 

Jzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). Operation x & y denotes bitwise AND operation of two numbers.

Input

The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).

Output

Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).

Examples

Input

3
2 3 3


Output

0


Input

4
0 1 2 3


Output

10


Input

6
5 2 0 5 2 1


Output

53

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
public class Main
{
	final long mod=(long)(1e9+7);
	final int bigmask=(1<<20)-1;
	private void solve()throws Exception
	{
		int n=nextInt();
		int freq[]=new int[bigmask+1];
		for(int i=1;i<=n;i++)
			freq[nextInt()]++;
		//dp[bit][mask] is the number of elements such that
		//the last bit bits are supermask of mask and rest bits are identical to mask
		int dp[][]=new int[21][bigmask+1];
		for(int bit=0;bit<=20;bit++)
			for(int mask=0;mask<=bigmask;mask++)
			{
				if(bit==0)
				{
					dp[bit][mask]=freq[mask];
					continue;
				}
				dp[bit][mask]=dp[bit-1][mask];
				if(((mask>>(bit-1))&1)==0)
					dp[bit][mask]+=dp[bit-1][mask+(1<<(bit-1))];
			}
		long ans=0;
		for(int mask=0;mask<=bigmask;mask++)
			if(Integer.bitCount(mask)%2==0)
				ans=(ans+((modpow(2,dp[20][mask])-1+mod)%mod))%mod;
			else
				ans=(ans-((modpow(2,dp[20][mask])-1+mod)%mod)+mod)%mod;
		out.println(ans);
	}
	long modpow(long a,long b){
	    long ret=1;
	    while(b!=0)
	    {
	        if(b%2==1)
	            ret=(ret*a)%mod;
	        a=(a*a)%mod;
	        b=b/2;
	    }
	    return ret;
	} 
	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}