{"problem":{"name":"Mandarin Orange","description":{"content":"There are $N$ dishes arranged in a row in front of Takahashi. The $i$\\-th dish from the left has $A_i$ oranges on it. Takahashi will choose a triple of integers $(l, r, x)$ satisfying all of the follo","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":1500,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc189_c"},"statements":[{"statement_type":"Markdown","content":"There are $N$ dishes arranged in a row in front of Takahashi. The $i$\\-th dish from the left has $A_i$ oranges on it.\nTakahashi will choose a triple of integers $(l, r, x)$ satisfying all of the following conditions:\n\n*   $1\\leq l \\leq r \\leq N$;\n*   $1 \\le x$;\n*   for every integer $i$ between $l$ and $r$ (inclusive), $x \\le A_i$.\n\nHe will then pick up and eat $x$ oranges from each of the $l$\\-th through $r$\\-th dishes from the left.\nAt most how many oranges can he eat by choosing the triple $(l, r, x)$ to maximize this number?\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\leq N \\leq 10^4$\n*   $1 \\leq A_i \\leq 10^5$\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":"abc189_c","tags":[],"sample_group":[["6\n2 4 4 9 4 9","20\n\nBy choosing $(l,r,x)=(2,6,4)$, he can eat $20$ oranges."],["6\n200 4 4 9 4 9","200\n\nBy choosing $(l,r,x)=(1,1,200)$, he can eat $200$ oranges."]],"created_at":"2026-03-03 11:01:14"}}