'Arijit Singh ke gaano ke baad bachpan se single log bhi apni EX ko yaad karne lag jaate hain!'
This is the problem with ACM. The Single/Commited ratio is too high. To tackle the problem, ACM is planning to launch a Scheme in which every person to solve the given problem will get a chance to go on a date with anyone he/she likes.
You are given an array A of size N. Let's define EX-Factor of a subsequenceA1,A2,A3,A4...AK as:
EX−Factor=A1−A2+A3−A4...(−1K−1)∗AK
You have to answer multiple queries.
Each query contains an integer X. Find the number of subsequences with EX-Factor equal to X.
NOTE: The first person to solve this problem is free to negotiate for reimbursement of the date.
INPUT FORMAT:
First-line contains an integer, N.
Next line contains N space-separated integers, Ai.
The next line contains Q, the number of queries.
Each of the following Q lines contains X mentioned above.
OUTPUT FORMAT:
Output answers for each query in a new line.
CONSTRAINTS:
1<=N<=32
1<=Q<=100
−109<=Ai<=109
−109<=X<=109
For the first query, the subsequence A1,A2,A3 has EX-Factor equal to 6.
For the third query, the subsequence A5 has EX-Factor equal to 8.