Under construction

Still being built. Things may change

Game with stones

Time limit1sMemory limit256 MB

Summary
Count the ways to color each of n piles black or white so that Bob wins the Steins;Game under optimal play, modulo 1000000007.
Level

Hard9 of 10

Topics
Game theory, Bit manipulation, Combinatorics, Dynamic programming
Solved
No attempts yet

Problem

Have you ever heard of the Nim game? Most likely, yes. But you have probably never heard of a newer game called "Steins;Game". It is played with many piles of stones, and Stein means stone in German.

Alice and Bob want to play this game. The game is played as follows:

There are nn piles of stones arranged in a row. Each pile is colored either white or black. The ii-th pile has aia_i stones. Starting with Alice, the two players take turns doing one of the following:

  • take any positive number of stones from the smallest black pile (the smallest one among all black piles); or
  • take any positive number of stones from any white pile.

The game ends when no stones remain, and the player who makes the next move loses the game.

All piles of stones are now fixed, but they are not yet colored. Bob has bribed the referee to get the chance to paint all the piles himself. How many ways can he paint the piles so that he wins, assuming Alice and Bob both play optimally? Since the answer may be very large, output it modulo 1 000 000 0071\,000\,000\,007.

Input

The first line contains one integer nn (1≤n≤105)(1\leq n\leq 10^5), the number of piles in the game.

The second line contains nn integers a1,a2,⋯ ,ana_1,a_2,\cdots,a_n (1≤ai≤1018)(1\leq a_i\leq 10^{18}), the number of stones in each pile.

Output

Print one integer on a line, the number of ways to paint the piles so that Bob wins, modulo 1 000 000 0071\,000\,000\,007.

Hint

For the first test case, Bob wins under any of the four ways to paint the piles.

For the second test case, the only way for Bob to win is to paint both piles black. Alice is then forced to take from the first pile on her first move, and Bob takes the whole second pile and wins.

For the third test case, no matter how Bob paints the only pile, Alice takes the whole pile and wins.

Examples3

  1. Example 1

    Input
    2
    1 1
    
    Expected output
    4
    
  2. Example 2

    Input
    2
    1 2
    
    Expected output
    1
    
  3. Example 3

    Input
    1
    3
    
    Expected output
    0