{"problem":{"name":"Chinese Restaurant","description":{"content":"Person $0$, Person $1$, $\\ldots$, and Person $(N-1)$ are sitting around a turntable in their counterclockwise order, evenly spaced. Dish $p_i$ is in front of Person $i$ on the table.   You may perform","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc268_c"},"statements":[{"statement_type":"Markdown","content":"Person $0$, Person $1$, $\\ldots$, and Person $(N-1)$ are sitting around a turntable in their counterclockwise order, evenly spaced. Dish $p_i$ is in front of Person $i$ on the table.  \nYou may perform the following operation $0$ or more times:\n\n*   Rotate the turntable by one $N$\\-th of a counterclockwise turn. As a result, the dish that was in front of Person $i$ right before the rotation is now in front of Person $(i+1) \\bmod N$.\n\nWhen you are finished, Person $i$ is happy if Dish $i$ is in front of Person $(i-1) \\bmod N$, Person $i$, or Person $(i+1) \\bmod N$.  \nFind the maximum possible number of happy people.\nWhat is $a \\bmod m$? For an integer $a$ and a positive integer $m$, $a \\bmod m$ denotes the integer $x$ between $0$ and $(m-1)$ (inclusive) such that $(a-x)$ is a multiple of $m$. (It can be proved that such $x$ is unique.)\n\n## Constraints\n\n*   $3 \\leq N \\leq 2 \\times 10^5$\n*   $0 \\leq p_i \\leq N-1$\n*   $p_i \\neq p_j$ if $i \\neq j$.\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$p_0$ $\\ldots$ $p_{N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc268_c","tags":[],"sample_group":[["4\n1 2 0 3","4\n\nThe figure below shows the table after one operation.\n![image](https://img.atcoder.jp/abc268/70536a7b7fad87d6a49ad00df89a4a30.png)\nHere, there are four happy people:\n\n*   Person $0$ is happy because Dish $0$ is in front of Person $3\\ (=(0-1) \\bmod 4)$;\n*   Person $1$ is happy because Dish $1$ is in front of Person $1\\ (=1)$;\n*   Person $2$ is happy because Dish $2$ is in front of Person $2\\ (=2)$;\n*   Person $3$ is happy because Dish $3$ is in front of Person $0\\ (=(3+1) \\bmod 4)$.\n\nThere cannot be five or more happy people, so the answer is $4$."],["3\n0 1 2","3"],["10\n3 9 6 1 7 2 8 0 5 4","5"]],"created_at":"2026-03-03 11:01:14"}}