QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#465. Stone Game

Statistics

Alice and Bob are playing an ancient game. There are several piles of stones, and Alice and Bob take turns removing any number of stones from a chosen pile, but they must remove at least one stone. The player who makes the last move, leaving the other player with no stones to take, wins.

There are $N$ piles of stones on the field, numbered $1$ to $N$. Alice quickly discovered that this game has a fixed strategy. The devious Alice wants to win this game, so she comes to you, the organizer, hoping that you will select a subset of these $N$ piles to be used in the final game such that Alice can win. You naturally do not want Alice to succeed, so you propose a condition: you will specify the index of the pile from which Alice must make her first move (you only specify the index of the pile, not how many stones she must take; the specified pile must be included in the subset of piles chosen for the game).

Now you are curious: you want to calculate how many ways there are for Alice to be unable to win. Note that even if the set of indices of the chosen piles is identical, different specified indices for the first move are considered different schemes.

Input

The first line contains a positive integer $N$, representing the number of piles.

The second line contains $N$ positive integers, representing the number of stones in each pile, given in order from index $1$ to $N$.

Output

A single line representing the number of schemes. The answer should be taken modulo $10^9+7$.

Examples

Input 1

3
2 4 5

Output 1

5

Note 1

Scheme 1: Choose piles $1$ and $2$, specify pile $1$.

Scheme 2: Choose piles $1$ and $3$, specify pile $1$.

Scheme 3: Choose piles $1$, $2$, and $3$, specify pile $2$.

Scheme 4: Choose piles $1$, $2$, and $3$, specify pile $3$.

Scheme 5: Choose piles $2$ and $3$, specify pile $2$.

Input 2

3
1 2 2

Output 2

6

Subtasks

Data ID $N$ Number of stones per pile
$1$ $\le 5$ $\le 5$
$2$ $\le 10$ $\le 10$
$3$ $\le 100$ $\le 100$
$4$ $\le 200$ $\le 200$
$5$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.