{"problem":{"name":"Min Max Pair","description":{"content":"You are given a sequence $a = (a_1, \\dots, a_N)$ of length $N$ consisting of integers between $1$ and $N$. Find the number of pairs of integers $i, j$ that satisfy all of the following conditions: * ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc262_c"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence $a = (a_1, \\dots, a_N)$ of length $N$ consisting of integers between $1$ and $N$.\nFind the number of pairs of integers $i, j$ that satisfy all of the following conditions:\n\n*   $1 \\leq i \\lt j \\leq N$\n*   $\\min(a_i, a_j) = i$\n*   $\\max(a_i, a_j) = j$\n\n## Constraints\n\n*   $2 \\leq N \\leq 5 \\times 10^5$\n*   $1 \\leq a_i \\leq N \\, (1 \\leq i \\leq N)$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$a_1$ $\\ldots$ $a_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc262_c","tags":[],"sample_group":[["4\n1 3 2 4","2\n\n$(i, j) = (1, 4), (2, 3)$ satisfy the conditions."],["10\n5 8 2 2 1 6 7 2 9 10","8"]],"created_at":"2026-03-03 11:01:14"}}