PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000223. Đa tập có phép XOR nguyên tố (Prime XOR)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đa tập có phép XOR nguyên tố (Prime XOR)

Prime XOR

Source: HackerRank

Version: Phuoc Hung OJ Extended

Problem Statement

Penny has an array of nn integers. She chooses a sub-multiset of its elements, using a value no more often than it occurs. Two choices are the same multiset when every integer has the same multiplicity in both choices, regardless of which positions were chosen.

The bitwise XOR of a multiset is the XOR of all its selected values. The empty multiset has XOR 00 and is not counted as prime.

Count the number of distinct multisets whose bitwise XOR is prime. Output the count modulo 109+710^9+7.

Input

The first line contains nn. The second line contains exactly nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print the count of distinct sub-multisets with prime XOR, modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 3500≤ai≤45003500\le a_i\le4500 for every ii.

  • Subtask 2 (30 points): 1≤n≤10001\le n\le1000; 3500≤ai≤45003500\le a_i\le4500 for every ii.

  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 3500≤ai≤45003500\le a_i\le4500 for every ii.

Examples

Input

3
3511 3671 4153

Output

4

Explanation

The input contains three different values. There are 23=82^3=8 sub-multisets including the empty one. The valid multisets are {3511}\{3511\}, {3671}\{3671\}, {4153}\{4153\}, and {3511,3671,4153}\{3511,3671,4153\}. Their XOR values are respectively 3511,3671,4153,50813511,3671,4153,5081, all prime. The three size-two choices give 992,7566,7790992,7566,7790 (even and greater than 22), while the empty choice gives 00. Exactly 44 choices qualify.