1933 - 夹心饼干
Description

给定一个数列 a_1,a_2,\dots,a_n,请求出在这个序列中,存在多少个夹心饼干。

所谓夹心饼干,就是从数列中挑出三个数 a_i,a_j,a_k,满足 i<j<k 且 a_i=a_k, 且 a_j ≠ a_k


Input

第一行:单个整数 n

第二行:n个整数表示  a_1,a_2,\dots,a_n

Output
  • 单个整数:表示夹心饼干的数量。


Examples

Input

5
1 2 1 2 1 

Output

5
Hint

30% 的数据,n\leq 100

60% 的数据,n\leq 20000

100% 的数据,n\leq 300,000

1\leq a_i < n


题目参数
Time Limit 1 second
Memory Limit 128 MB
提交次数 54
通过次数 17