{"problem":{"name":"F. Financiers Game","description":{"content":"_This problem has unusual memory constraint._ At evening, Igor and Zhenya the financiers became boring, so they decided to play a game. They prepared _n_ papers with the income of some company for so","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":524288},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF738F"},"statements":[{"statement_type":"Markdown","content":"_This problem has unusual memory constraint._\n\nAt evening, Igor and Zhenya the financiers became boring, so they decided to play a game. They prepared _n_ papers with the income of some company for some time periods. Note that the income can be positive, zero or negative.\n\nIgor and Zhenya placed the papers in a row and decided to take turns making moves. Igor will take the papers from the left side, Zhenya will take the papers from the right side. Igor goes first and takes 1 or 2 (on his choice) papers from the left. Then, on each turn a player can take _k_ or _k_ + 1 papers from his side if the opponent took exactly _k_ papers in the previous turn. Players can't skip moves. The game ends when there are no papers left, or when some of the players can't make a move.\n\nYour task is to determine the difference between the sum of incomes on the papers Igor took and the sum of incomes on the papers Zhenya took, assuming both players play optimally. Igor wants to maximize the difference, Zhenya wants to minimize it.\n\n## Input\n\nThe first line contains single positive integer _n_ (1 ≤ _n_ ≤ 4000) — the number of papers.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_ ( - 105 ≤ _a__i_ ≤ 105), where _a__i_ is the income on the _i_\\-th paper from the left.\n\n## Output\n\nPrint the difference between the sum of incomes on the papers Igor took and the sum of incomes on the papers Zhenya took, assuming both players play optimally. Igor wants to maximize the difference, Zhenya wants to minimize it.\n\n[samples]\n\n## Note\n\nIn the first example it's profitable for Igor to take two papers from the left to have the sum of the incomes equal to 4. Then Zhenya wouldn't be able to make a move since there would be only one paper, and he would be able to take only 2 or 3..","is_translate":false,"language":"English"}],"meta":{"iden":"CF738F","tags":["dp","games"],"sample_group":[["3\n1 3 1","4"],["5\n-1 -2 -1 -2 -1","0"],["4\n-4 -2 4 5","\\-13"]],"created_at":"2026-03-03 11:00:39"}}