{"problem":{"name":"1 or 2","description":{"content":"Snuke has a blackboard and $N$ candies. The _tastiness_ of the $i$\\-th candy is $a_i$. He will repeat the operation below until he has no more candy. *   Choose one or two of his candies and eat them","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc121_d"},"statements":[{"statement_type":"Markdown","content":"Snuke has a blackboard and $N$ candies. The _tastiness_ of the $i$\\-th candy is $a_i$.\nHe will repeat the operation below until he has no more candy.\n\n*   Choose one or two of his candies and eat them (of course, they disappear). Then, write on the blackboard the total tastiness of the candies he has just chosen.\n\nSnuke wants to minimize $X-Y$, where $X$ and $Y$ are the largest and smallest values written on the blackboard, respectively. Find the minimum possible value of $X-Y$.\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\leq N \\leq 5000$\n*   $-10^{9} \\leq a_i \\leq 10^9$\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":"arc121_d","tags":[],"sample_group":[["3\n1 2 4","1\n\n*   One optimal sequence of operations is to eat the candies with the tastinesses of $1$ and $2$ in the first operation, and then eat the candies with the tastiness of $4$ in the second operation."],["2\n-100 -50","0\n\n*   It is optimal to eat both candies with the tastiness of $-100$ and $-50$ in the first operation."],["20\n-18 31 -16 12 -44 -5 24 17 -37 -31 46 -24 -2 11 32 16 0 -39 35 38","13"]],"created_at":"2026-03-03 11:01:14"}}