#P9102. [PA 2020] Cukierki
[PA 2020] Cukierki
Problem Description
This problem is translated from PA 2020 Round 5 Cukierki.
Bytie is going to Bitek’s birthday party. He knows that Bitek likes sweets, so he wants to give him some candies as a gift. He bought bags of candies, and the -th bag contains candies.
However, these candies are quite heavy, and Bytie wants to know whether he needs to give all of them to Bitek. He decides that he will choose a non-empty subset of the bags, take them to Bitek, and say: “I have a total of candies here, how many do you want?”, where is the total number of candies in the bags brought to the party. After hearing this, Bitek may choose any integer in the range . No matter what Bitek answers, Bytie wants to be able to select some of the bags he brought (and keep the rest for himself) so that the total number of candies in the selected bags is exactly . Of course, he cannot tear the wrappers—giving loose candies is impolite.
Therefore, Bytie is thinking: how many different non-empty subsets of bags can he bring so that, regardless of Bitek’s choice, he can give him the desired number of candies? Please help him compute this. Since the number of such subsets may be very large, output it modulo .
Input Format
The first line contains an integer , the number of candy bags Bytie has.
The second line contains integers , where is the number of candies in the -th bag.
Output Format
Output the number of possible subsets of candy bags modulo .
5
2 7 4 4 1
8
Hint
Explanation for Sample 1
Bytie can bring non-empty subsets: $\{5\}, \{1, 5\}, \{1, 3, 5\}, \{1, 4, 5\}, \{1, 3, 4, 5\}, \{1, 2, 3, 5\}, \{1, 2, 4, 5\}$, and . For example, if Bytie brings the subset and Bitek wants candies, then Bytie can only give him bags and . Bytie cannot bring the subset , because if Bitek wants candies then Bytie would not be able to satisfy him.
Constraints
This problem uses bundled testdata.
For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5