{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence of positive integers of length $N$: $A=(A_1,A_2,\\ldots,A_N)$. Find the number of triples of positive integers $(i,j,k)$ that satisfy all of the following conditions:\n\n*   $1\\leq i < j < k\\leq N$,\n*   $A_i = A_k$,\n*   $A_i \\neq A_j$."},{"iden":"constraints","content":"*   $3\\leq N\\leq 3\\times 10^5$\n*   $1\\leq A_i \\leq N$\n*   All input values are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ \n$A_1$ $A_2$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"5\n1 2 1 3 2"},{"iden":"sample output 1","content":"3\n\nThe following three triples of positive integers $(i,j,k)$ satisfy the conditions:\n\n*   $(i,j,k)=(1,2,3)$\n*   $(i,j,k)=(2,3,5)$\n*   $(i,j,k)=(2,4,5)$"},{"iden":"sample input 2","content":"7\n1 2 3 4 5 6 7"},{"iden":"sample output 2","content":"0\n\nThere may be no triples of positive integers $(i,j,k)$ that satisfy the conditions."},{"iden":"sample input 3","content":"13\n9 7 11 7 3 8 1 13 11 11 11 6 13"},{"iden":"sample output 3","content":"20"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}