Let
be a prime number. You are given three integers .
First, define negative exponents as follows. When , is the unique integer satisfying
For an integer , define as follows.
If an integer satisfies
then is called a possible value of .
Given , output the sum of all possible integers .
Here, is considered as an integer satisfying
The input is given in the following format.
Output the sum of all integers satisfying
Since , we have . Therefore, the answer is .
The value satisfying is the modular inverse of , which is .
We have .