{"raw_statement":[{"iden":"statement","content":"Given a sequence $a_1, a_2, \\ldots, a_n$.\n\nYou are going to select zero or more elements of $a$ so that: if you select $a_i$, then in any interval of length $i$ (formally, in $a[j, j + i - 1]$ for any $1 \\le j \\le n - i + 1$) you can select at most $2$ elements.\n\nCalculate the maximal sum of the elements you select."},{"iden":"input","content":"The first line contains an integer $n$ ($2 \\leq n \\leq 10^5$).\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($-10^9 \\leq a_i \\leq 10^9$)."},{"iden":"output","content":"Output a single integer denoting the answer."},{"iden":"note","content":"**Source**: The 2022 ICPC Asia Xi'an Regional Contest Problem J.\n\n**Author**: JohnVictor."}],"translated_statement":null,"sample_group":[["4\n1 4 3 2\n","7\n"],["3\n-10 -10 -10\n","0"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}