Input: N = 5, A[] = {1, 2, 3, 2, 4}
Output: 7
Explanation: We can get 7 permutations: {1}, {1, 2}, {1, 2}, {1, 2, 3}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 3, 4}.
Input: N = 4, A[] = {2, 1, 1, 2}
Output: 6
Explanation: We can get 6 permutations: {1}, {1}, {2, 1}, {2, 1}, {1, 2}, {1, 2}