{"problem":{"name":"Stones","description":{"content":"Takahashi and Aoki will play a game of taking stones using a sequence $(A_1, \\ldots, A_K)$. There is a pile that initially contains $N$ stones. The two players will alternately perform the following o","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc270_d"},"statements":[{"statement_type":"Markdown","content":"Takahashi and Aoki will play a game of taking stones using a sequence $(A_1, \\ldots, A_K)$.\nThere is a pile that initially contains $N$ stones. The two players will alternately perform the following operation, with Takahashi going first.\n\n*   Choose an $A_i$ that is at most the current number of stones in the pile. Remove $A_i$ stones from the pile.\n\nThe game ends when the pile has no stones.\nIf both players attempt to maximize the total number of stones they remove before the end of the game, how many stones will Takahashi remove?\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^4$\n*   $1 \\leq K \\leq 100$\n*   $1 = A_1 < A_2 < \\ldots < A_K \\leq N$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$\n$A_1$ $A_2$ $\\ldots$ $A_K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc270_d","tags":[],"sample_group":[["10 2\n1 4","5\n\nBelow is one possible progression of the game.\n\n*   Takahashi removes $4$ stones from the pile.\n*   Aoki removes $4$ stones from the pile.\n*   Takahashi removes $1$ stone from the pile.\n*   Aoki removes $1$ stone from the pile.\n\nIn this case, Takahashi removes $5$ stones. There is no way for him to remove $6$ or more stones, so this is the maximum.\nBelow is another possible progression of the game where Takahashi removes $5$ stones.\n\n*   Takahashi removes $1$ stone from the pile.\n*   Aoki removes $4$ stones from the pile.\n*   Takahashi removes $4$ stones from the pile.\n*   Aoki removes $1$ stone from the pile."],["11 4\n1 2 3 6","8\n\nBelow is one possible progression of the game.\n\n*   Takahashi removes $6$ stones.\n*   Aoki removes $3$ stones.\n*   Takahashi removes $2$ stones.\n\nIn this case, Takahashi removes $8$ stones. There is no way for him to remove $9$ or more stones, so this is the maximum."],["10000 10\n1 2 4 8 16 32 64 128 256 512","5136"]],"created_at":"2026-03-03 11:01:13"}}