##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
For a sequence , define as the smallest non-negative integer that does not appear in .
You are given an array .
You want to partition the array into one or more non-empty contiguous subarrays. A partition is called good if the mex of all subarrays in the partition are equal.
Count the number of good partitions modulo .
Two partitions are considered different if the positions of their cuts are different.
No segment contains , so every way of placing cuts is valid. For an array of length , there are partitions.
The valid partitions are and .
The whole array has mex . Any non-trivial cut leaves a part without one of , so only the whole array works.
Every part must contain both and . There are possible partitions.
The valid partitions are and .