TSSOJ
View as PDFSiddharth spends all day and night setting TSSOJ problems.
He has mastered different problem-writing techniques. Initially, his skill in every technique is
.
Siddharth plans to write exactly problems. For each problem, he may choose any one of the
techniques to use. However, he gets bored easily, so he will use technique
at most
times.
The quality of a problem is equal to Siddharth’s current skill in the chosen technique. After writing the problem, his skill in that technique doubles. His skills in all other techniques remain unchanged.
Siddharth wants to maximize the total quality of the problems he writes.
Given ,
, and the limits
, determine the maximum possible total quality. Maximize the true total first, then output it modulo
.
Input
The first line contains integer
, representing the number of techniques Siddharth can use.
The second line contains integer
, representing the number of problems he will write.
The next lines contain integers
, where
.
It is guaranteed that . Note that this sum may not fit in a 64-bit integer.
Output
Output the maximum possible total quality, modulo .
Comments