CF1400D Zigzags

题目描述

给出 $n$ 个数 $a_1,a_2,\cdots,a_n$。求问有多少个四元组 $(i,j,k,l)$,使得这个四元组满足下列条件: - $1 \leq i

输入格式

输出格式

说明/提示

In the first test case, for any four indices $ i < j < k < l $ are valid, so the answer is the number of tuples. In the second test case, there are $ 2 $ valid tuples: - $ (1, 2, 4, 6) $ : $ a_1 = a_4 $ and $ a_2 = a_6 $ ; - $ (1, 3, 4, 6) $ : $ a_1 = a_4 $ and $ a_3 = a_6 $ .