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.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Rubanenko
 */
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 {
    final int MAX_VALUE = 1 << 20;
    final int MD = 1000000000 + 7;
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[MAX_VALUE];
        int[] c = new int[MAX_VALUE];
        int[] deg = new int[MAX_VALUE];
        long[] f = new long[MAX_VALUE];
        deg[0] = 1;
        for (int i = 1; i < MAX_VALUE; i++) {
            deg[i] = deg[i - 1] * 2;
            if (deg[i] >= MD) deg[i] -= MD;
        }
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
           // int x = i;
            a[x]++;
            f[x]++;
            c[x]++;
        }
        long[] ff = new long[MAX_VALUE];
        int ans = deg[n] - 1;
        if (ans < 0) ans += MD;
        long[] fact = new long[23];
        fact[0] = 1;
        for (int i = 1; i <= 21; i++) {
            fact[i] = fact[i - 1] * ((long) i);
        }

        for (int j = 0; j < 20; j++) {
        for (int mask = MAX_VALUE - 1; mask > 0; mask--) {
                if (f[mask] > 0) {
                    for (int i = 0; i < 20; i++) {
                        if (((1 << i) & mask) > 0) ff[mask ^ (1 << i)] += f[mask];
                    }
                }
            }
            for (int mask = MAX_VALUE - 1; mask > 0; mask--) {
                c[mask] += ff[mask] / fact[j + 1];
                f[mask] = ff[mask];
                ff[mask] = 0;
            }
        }
        for (int mask = 1; mask < MAX_VALUE; mask++) {
            if ((Integer.bitCount(mask) & 1) == 1) ans -= deg[c[mask]] - 1;
            else ans += deg[c[mask]] - 1;
            if (ans >= MD) ans -= MD;
            if (ans < 0) ans += MD;
        }
        out.println(ans);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

    public String nextLine() {
        String line = null;
        try {
            line = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return line;
    }

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

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