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 static java.lang.Math.pow;
import java.math.BigInteger.*;
import static java.math.BigInteger.*;
import java.util.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.fill;

//<editor-fold defaultstate="collapsed" desc="Imports">
//</editor-fold>
// https://netbeans.org/kb/73/java/editor-codereference_ru.html#display
//<editor-fold defaultstate="collapsed" desc="Main">
public class Main {
    private void run() {
        Locale.setDefault(Locale.US);
        boolean oj = true;
        try {
            oj = System.getProperty("MYLOCAL") == null;
        } catch (Exception e) {
        }
        
        if (oj) {
            sc = new FastScanner(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
        } else {
            try {
                sc = new FastScanner(new FileReader("input.txt"));
                out = new PrintWriter(new FileWriter("output.txt"));
            } catch (IOException e) {
                MLE();
            }
        }
        Solver s = new Solver();
        s.sc = sc;
        s.out = out;
        s.solve();
        err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
        out.flush();
    }
    
    private void show(int[] arr) {
        for (int v : arr) {
            err.print(" " + v);
        }
        err.println();
    }
    
    public static void MLE() {
//        int[][] arr = new int[1024 * 1024][];
//        for (int i = 0; i < arr.length; i++) {
//            arr[i] = new int[1024 * 1024];
//        }
        System.exit(0);
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
    
    long timeBegin = System.currentTimeMillis();
    FastScanner sc;
    PrintWriter out;
    PrintStream err = System.err;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc="FastScanner">
class FastScanner {
    
    BufferedReader br;
    StringTokenizer st;
    
    FastScanner(InputStreamReader reader) {
        br = new BufferedReader(reader);
        st = new StringTokenizer("");
    }
    
    String next() {
        while (!st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ex) {
                Main.MLE();
            }
        }
        return st.nextToken();
    }
    
    int nextInt() {
        return Integer.parseInt(next());
    }
    
    long nextLong() {
        return Long.parseLong(next());
    }
}
//</editor-fold>


class Solver {

    FastScanner sc;
    PrintWriter out;
    PrintStream err = System.err;

    
    final int cntBits = 20, mod = (int)1e9 + 7;
    int n;
    int[] a;
    int[] f = new int[1<<cntBits];
    final long[] pow2 = new long[1<<cntBits];
    {
        pow2[0] = 1;
        for (int i = 1; i < pow2.length; i++) {
            pow2[i] = (pow2[i-1] * 2) % mod;
        }
    }
    
    void solve(){
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            ++f[a[i]];
        }
//        bf();
        for (int k = 1; k <= cntBits; k++) {
            for (int msk = 0; msk < (1<<cntBits); msk++) {
                if( (msk&(1<<(k-1))) == 0 )
                    f[msk] = (f[msk] + f[msk+(1<<(k-1))]) % mod;
            }
        }
//        err.println(Arrays.toString(f[cntBits]));
        long ans = 0;
        for (int msk = 0; msk < (1<<cntBits); msk++) {
            long cur = pow2[f[msk]];
            if( Integer.bitCount(msk)%2==0 )
                ans += cur;
            else
                ans -= cur;
        }
        ans = ( ans % mod + mod ) % mod;
        out.println( ans );
    }

//    void bf() {
//        int[] ffff = new int[1<<cntBits];
//        for (int ai : a) {
//            for (int x = 0; x < ffff.length; x++) {
//                if ((ai & x) == x) {
//                    ++ffff[x];
//                }
//            }
//        }
//        err.println(Arrays.toString(ffff));
//
//        double ans = 0;
//        for (int x = 0; x < ffff.length; x++) {
//            ans += pow(-1, Integer.bitCount(x)) * pow(2, ffff[x]);
//            out.printf("%4s %d %3.0f\n",
//                    Integer.toBinaryString(x),
//                    ffff[x],
//                    pow(-1, Integer.bitCount(x)) * pow(2, ffff[x]));
//        }
//        out.println(ans);
//    }
}