M. ABAB
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Baozii Cup problems have always been known for their succinct problem statements. This one is no exception.

You are given an array $$$a$$$ of length $$$n$$$. Count the number of quadruplets of integers $$$(i,j,k,l)$$$ that satisfy the following conditions:

  • $$$1 \le i \lt j \lt k \lt l \le n$$$.
  • $$$(a_i=a_k) \land (a_j=a_l) \land (a_i \ne a_j)$$$.
Input

The first line of each test contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$.

The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le n$$$) — the elements of $$$a$$$.

Output

Output the number of quadruplets of integers satisfying the conditions on a single line.

Examples
Input
6
1 1 4 5 1 4
Output
2
Input
7
1 1 2 1 2 2 1
Output
6