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.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    private static final int MOD = (int) 1e9 + 7;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = Utils.readIntArray(in, n);
        int[] dp = new int[1 << 20];
        int[] next = new int[1 << 20];
        for (int i = 0; i < n; ++i) {
            dp[a[i]]++;
        }
        for (int k = 0; k < 20; ++k) {
            for (int mask = 0; mask < (1 << 20); ++mask) {
                next[mask] += dp[mask];
                if (next[mask] >= MOD) next[mask] -= MOD;
                if (!BitUtils.checkBit(mask, k)) {
                    next[mask] += dp[BitUtils.setBit(mask, k)];
                    if (next[mask] >= MOD) next[mask] -= MOD;
                }
            }
            int[] temp = dp;
            dp = next;
            next = temp;
            Arrays.fill(next, 0);
        }
        int res = IntegerUtils.pow(2, n, MOD) - 1;
        if (res < 0) res += MOD;
        for (int mask = 1; mask < (1 << 20); ++mask) {
            int sign = 1;
            if ((Integer.bitCount(mask) & 1) == 1) {
                sign = -1;
            }
            res += sign * ((IntegerUtils.pow(2, dp[mask], MOD) - 1 + MOD) % MOD);
            while (res < 0) res += MOD;
            while (res >= MOD) res -= MOD;
        }
        out.println(res);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine().trim();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

class Utils {
    public static int[] readIntArray(InputReader in, int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }
        return a;
    }

}

class BitUtils {
    public static boolean checkBit(int mask, int bit) {
        return (mask & (1 << bit)) > 0;
    }

    public static int setBit(int mask, int bit) {
        return (mask | (1 << bit));
    }

}

class IntegerUtils {

    public static int pow(int x, int p, int MOD) {
        int result = 1;
        for (int i = p; i > 0; i >>= 1) {
            if ((i & 1) != 0) {
                result = (int) ((result * 1L * x) % MOD);
            }
            x = (int) ((x * 1L * x) % MOD);
        }
        return result;
    }

}