GCD Subset Challenge
Problem Statement
In the ancient Kingdom of Rhun, mathematicians believed that numbers possessed magical properties when combined in the right way. During the annual Festival of Numbers, villagers are challenged to create groups from a given set of mystical integers. The challenge is to form a non-empty subset of these integers such that the greatest common divisor (GCD) of the subset equals . Only those groups with are said to invoke the ancient magic.
Your task is to help the villagers determine the number of ways to choose a non-empty subset from the given array of integers such that the GCD of all the numbers in that subset is exactly . Since the number of possible subsets can be huge, report the answer modulo .
Input Format
- The first line contains a single integer (), representing the number of integers.
- The second line contains space-separated positive integers where each satisfies .
Output Format
- Output a single integer representing the number of non-empty subsets with , taken modulo .
Examples
Input
3
1 2 3
Output
5
Input
4
2 4 8 16
Output
0
Code Editor
Submit a solution. Authentication is required to create submissions.