#exawizards2019d. [exawizards2019_d]Modulo Operations
[exawizards2019_d]Modulo Operations
Problem Statement
Snuke has a blackboard and a set consisting of integers. The -th element in is .
He wrote an integer on the blackboard, then performed the following operation times:
- Choose one element from and remove it.
- Let be the number written on the blackboard now, and be the integer removed from . Replace the number on the blackboard with .
There are possible orders in which the elements are removed from . For each of them, find the number that would be written on the blackboard after the operations, and compute the sum of all those numbers modulo .
Constraints
- All values in input are integers.
- are pairwise distinct.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
Sample Output 1
- There are two possible orders in which we remove the numbers from .
- If we remove and in this order, the number on the blackboard changes as follows: .
- If we remove and in this order, the number on the blackboard changes as follows: .
- The output should be the sum of these: .
Sample Input 2
Sample Output 2
Sample Input 3
Sample Output 3
- Be sure to compute the sum modulo .