#P1696H. Maximum Product?
Maximum Product?
Description
You are given a positive integer . For a multiset of integers , define as the following.
- If the number of elements in is less than , .
- Otherwise, define as the maximum product you can get by choosing exactly integers from .
More formally, let denote the number of elements in . Then,
- If , .
- Otherwise, .
You are given a multiset of integers, . Compute modulo .
Note that in this problem, we distinguish the elements by indices instead of values. That is, a multiset consisting of elements always has distinct subsets regardless of whether some of its elements are equal.
The first line of input contains two integers and , where is the number of elements in ().
The second line of input contains integers , describing the elements in ().
Output modulo .
Input
The first line of input contains two integers and , where is the number of elements in ().
The second line of input contains integers , describing the elements in ().
Output
Output modulo .
Note
Consider the first sample. From the definitions we know that
So we should print .
In the second example, note that although the multiset consists of three same values, it still has distinct subsets: .