Let's call a sequence of integers a1, a2, ..., aN _almost monotonic_ if first K elements are non-decreasing sequence and last N-K+1 elements are non- increasing sequence: a1≤a2≤...≤aK and aK≥aK+1≥...≥aN. The _diversity number_ of a sequence a1, a2, ..., aN is the number of possible sequences b1, b2,..., bN for which 0≤bi