{"problem":{"name":"-1+2-1","description":{"content":"Given is an integer sequence of length $N$: $A=(A_1,A_2,\\cdots,A_N)$. You can repeat the operation below any number of times. *   Choose an integer $i$ ($1 \\leq i \\leq N$) and add $-1, 2, -1$ to $A_{","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc129_d"},"statements":[{"statement_type":"Markdown","content":"Given is an integer sequence of length $N$: $A=(A_1,A_2,\\cdots,A_N)$.\nYou can repeat the operation below any number of times.\n\n*   Choose an integer $i$ ($1 \\leq i \\leq N$) and add $-1, 2, -1$ to $A_{i-1},A_i,A_{i+1}$, respectively. Here, $A_0$ stands for $A_N$, and $A_{N+1}$ stands for $A_1$.\n\nDetermine whether it is possible to make every element of $A$ $0$. If it is possible, find the minimum number of operations needed.\n\n## Constraints\n\n*   $3 \\leq N \\leq 200000$\n*   $-100 \\leq A_i \\leq 100$\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$ $A_2$ $\\cdots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc129_d","tags":[],"sample_group":[["4\n3 0 -1 -2","5\n\nWe can achieve the objective in five operations, as follows.\n\n*   Do the operation with $i=2$. Now we have $A=(2,2,-2,-2)$.\n*   Do the operation with $i=3$. Now we have $A=(2,1,0,-3)$.\n*   Do the operation with $i=3$. Now we have $A=(2,0,2,-4)$.\n*   Do the operation with $i=4$. Now we have $A=(1,0,1,-2)$.\n*   Do the operation with $i=4$. Now we have $A=(0,0,0,0)$."],["3\n1 0 -2","\\-1"],["4\n1 -1 1 -1","\\-1"],["10\n-28 -3 90 -90 77 49 -31 48 -28 -84","962"]],"created_at":"2026-03-03 11:01:14"}}