{"raw_statement":[{"iden":"problem statement","content":"$N$ people numbered $1,2,\\dots,N$ are standing in a row. Person $i$ wears Color $A_i$.\nAnswer $Q$ queries of the format below.\n\n*   You are given integers $l$ and $r$. Considering only Person $l,l+1,\\dots,r$, how many pairs of people wearing the same color can be formed at most?"},{"iden":"constraints","content":"*   All values in input are integers.\n*   $1 \\le N \\le 10^5$\n*   $1 \\le Q \\le 10^6$\n*   $1 \\le A_i \\le N$\n*   $1 \\le l \\le r \\le N$ in each query."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$\n$Q$\n$\\mathrm{Query}_1$\n$\\mathrm{Query}_2$\n$\\vdots$\n$\\mathrm{Query}_Q$\n\nHere, $\\mathrm{Query}_i$ represents the $i$\\-th query.\nEach query is in the following format:\n\n$l$ $r$"},{"iden":"sample input 1","content":"10\n1 2 3 2 3 1 3 1 2 3\n6\n6 10\n5 8\n3 6\n4 4\n1 6\n1 10"},{"iden":"sample output 1","content":"2\n2\n1\n0\n3\n4\n\nWe have $A=(1,2,3,2,3,1,3,1,2,3)$. This input contains six queries.\nThe first query is $(l, r) = (6, 10)$. By pairing Person $6, 8$ and paring Person $7, 10$, we can form two pairs of people wearing the same color.\nThe second query is $(l, r) = (5, 8)$. By pairing Person $5, 7$ and paring Person $6, 8$, we can form two pairs of people wearing the same color.\nThere can be a query where $l=r$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}