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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

/**
 * Created by hama_du on 2014/07/19.
 */
public class ProblemD {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] a = new int[n];
        int[] cnt = new int[1<<20];
        for (int i = 0 ; i < n ; i++) {
            a[i] = in.nextInt();
            cnt[a[i]]++;
        }

        long[] p2 = new long[1000010];
        p2[0] = 1;
        for (int i = 1 ; i < p2.length ; i++) {
            p2[i] = (p2[i-1] * 2) % MOD;
        }

        for (int i = 0 ; i < 20 ; i++) {
            for (int x = 0 ; x < (1<<20) ; x++) {
                if ((x & (1<<i)) == 0) {
                    cnt[x] += cnt[x | (1<<i)];
                }
            }
        }


        long total = (p2[n] + MOD - 1) % MOD;
        long answer = 0;
        for (int x = 1 ; x < (1<<20) ; x++) {
            long ptn = (p2[cnt[x]] + MOD - 1) % MOD;
            if ((Integer.bitCount(x) & 1) == 1) {
                answer += ptn;
            } else {
                answer += (MOD - ptn);
            }
        }
        answer %= MOD;

        answer = (total + 2 * MOD - answer) % MOD;
        answer %= MOD;

        out.println(answer);
        out.flush();
    }

    static long MOD = 1000000007;

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}