#P1043B. Lost Array
Lost Array
No submission language available for this problem.
Description
Bajtek, known for his unusual gifts, recently got an integer array .
Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek found on the arrays producer's website another array of length . As a formal description of says, and for all other () , where denotes the remainder of division by .
For example, if the and , then:
- ,
- ,
- ,
- ,
- ,
- .
So, if the and , then .
Now the boy hopes that he will be able to restore from ! Knowing that , help him and find all possible values of — possible lengths of the lost array.
The first line contains exactly one integer () — the length of the array , excluding the element .
The second line contains integers ().
Note that is always and is not given in the input.
The first line of the output should contain one integer denoting the number of correct lengths of the lost array.
The second line of the output should contain integers — possible lengths of the lost array in increasing order.
Input
The first line contains exactly one integer () — the length of the array , excluding the element .
The second line contains integers ().
Note that is always and is not given in the input.
Output
The first line of the output should contain one integer denoting the number of correct lengths of the lost array.
The second line of the output should contain integers — possible lengths of the lost array in increasing order.
Samples
Note
In the first example, any is suitable, since is an arithmetic progression.
Possible arrays :
In the second example, Bajtek's array can have three or five elements.
Possible arrays :
For example, is bad, since it leads to and , which is an obvious contradiction.
In the third example, only is good.
Array satisfies the requirements.
Note that may be negative.