#P11771. 调的啥啊
调的啥啊
Description
In the note sequence Aling is adjusting is notes in total. The -th note from the left has a pitch of . Aling discovered that three of the notes is bad to listen to, thus she decided to change them into , where and . However, operating on a touchpad is tough:
-
Adjusting to takes her points of energy.
-
Adjusting to takes her points of energy.
-
Adjusting to takes her points of energy.
Therefore, to finish the adjusting work on all the three notes, the points of energy she need is:
$$z=a\cdot|s_i-s_i'|+b\cdot|s_j-s_j'|+c\cdot|s_k-s_k'|.$$Aling surely will find that makes minimum. Let denote the minimum . Aling now wants to know the sum over all the s that . You're only required to output the ans modulo .
Input Format
The first line of input contains an integer — the length to the note sequence.
The second line of input contains three integers — the mentioned constants in the description.
The third line od input contains integers — the pitch of each note.
Output Format
One integer — the remainder of the sum over all the s that .
4
3 4 5
2 4 3 1
39
Hint
Sample Explanation
, one of the ideal s is .
, one of the ideal s is .
, one of the ideal s is .
, one of the ideal s is .
The sum of the s is .
Constraints
Subtasks Applied. You can only gain the score of the subtask if you accepted all the tests in the subtask.
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| No | |||
| Yes | |||
| No |
Special Property: the quantity of different pitches is at most .(i.e. there is at most 10 kinds of pitches.)
For all tests, it is guaranteed that ,.
京公网安备 11011102002149号