Input: 1
Output: 1
Explanation: N = 1, there is only one permutation of size 2 that have at least 1 increasing elements: [1, 2].
In permutation [1, 2], p1 < p2 , and there is one, i=1, that satisfy the condition. Since, 1 ≥ N this permutation should be counted.
In permutation [2, 1], p1 > p2 , and there is no increasing element since, 0<N, this permutation should not be counted.
Input: 2
Output: 12
Explanation: N = 2, there are 12 permutations of size 4 that have at least 2 increasing elements. Following are those permutations: [1, 2, 3, 4], [1, 2, 4, 3], [1, 3, 2, 4], [1, 3, 4, 2], [1, 4, 2, 3], [2, 1, 3, 4], [2, 3, 1, 4], [2, 3, 4, 1], [2, 4, 1, 3], [3, 1, 2, 4], [3, 4, 1, 2], [4, 1, 2, 3].
Assume a permutation P and let k be the total count of increasing elements in P. Assume a permutation Q obtained by reversing permutation P and let l be the total count of increasing elements in Q. Mathematically:
if P = [p1, p2, p3, . . ., p2N], then Q = [p2N, p2N-1, p2N-2, . . ., p2, p1].
k = ∑[pi−1 < pi] ∀ 2⩽ i ⩽ 2N
It can be observed that:
The number of increasing elements in Q = 2N - 1 - Number of increasing elements in P = l = 2N - 1 - k
This means, that for every permutation P having the number of increasing elements k < N, there exists a corresponding permutation Q, obtained by reversing P that has the number of increasing elements l ≥ N.