AT_abc429_c [ABC429C] Odd One Subsequence
Description
You are given an integer sequence of length $ N $ , $ A=(A_1,A_2,\ldots,A_N) $ .
Find the number of triples of integers $ (i,j,k) $ satisfying $ 1\leq i
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $
Output Format
Print the number of triples of integers that satisfy the condition.
Explanation/Hint
### Sample Explanation 1
For example, $ (i,j,k)=(1,2,4) $ satisfies the condition because exactly two distinct values, $ 2 $ and $ 3 $ , are contained in $ A_1=3 $ , $ A_2=2 $ , and $ A_4=2 $ .
Including this, the six triples $ (i,j,k)=(1,2,4),(1,2,5),(1,4,5),(2,3,4),(2,3,5),(3,4,5) $ satisfy the condition.
Therefore, print $ 6 $ .
### Sample Explanation 2
There may be no triples that satisfy the condition.
### Constraints
- $ 3 \leq N \leq 2\times 10^5 $
- $ 1 \leq A_i \leq N $
- All input values are integers.