{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence $A$ of length $N$ consisting of integers between $1$ and $\\textbf{10}$, inclusive.\nA pair of integers $(l,r)$ satisfying $1\\leq l \\leq r\\leq N$ is called a good pair if it satisfies the following condition:\n\n*   The sequence $(A_l,A_{l+1},\\ldots,A_r)$ contains a (possibly non-contiguous) arithmetic subsequence of length $3$. More precisely, there is a triple of integers $(i,j,k)$ with $l \\leq i < j < k\\leq r$ such that $A_j - A_i = A_k - A_j$.\n\nFind the number of good pairs."},{"iden":"constraints","content":"*   $3 \\leq N \\leq 10^5$\n*   $1\\leq A_i \\leq 10$\n*   All input numbers are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"5\n5 3 4 1 5"},{"iden":"sample output 1","content":"3\n\nThere are three good pairs: $(l,r)=(1,4),(1,5),(2,5)$.\nFor example, the sequence $(A_1,A_2,A_3,A_4)$ contains an arithmetic subsequence of length $3$, which is $(5,3,1)$, so $(1,4)$ is a good pair."},{"iden":"sample input 2","content":"3\n1 2 1"},{"iden":"sample output 2","content":"0\n\nThere may be cases where no good pairs exist."},{"iden":"sample input 3","content":"9\n10 10 1 3 3 7 2 2 5"},{"iden":"sample output 3","content":"3"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}