{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\nIt\u0027s yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mushrooms from different mountains. Each bag has a capacity of 2012 grams. Alice has finished picking mushrooms in 0 ≤ \u003cvar\u003en\u003c/var\u003e ≤ 5 mountains. In the the \u003cvar\u003ei\u003c/var\u003e-th mountain, she picked 0 ≤ \u003cvar\u003ew\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e ≤ 2012 grams of mushrooms. Now she is moving forward to the remained mountains. After finishing picking mushrooms in all the five mountains, she want to bring as much mushrooms as possible home to cook a delicious soup.\n\u003c/p\u003e\n\n\u003cp\u003e\nAlice lives in the forest of magic. At the entry of the forest of magic, lives three mischievous fairies, Sunny, Lunar and Star. On Alice\u0027s way back home, to enter the forest, she must give them exactly three bags of mushrooms whose total weight must be of integral kilograms. If she cannot do so, she must leave all the five bags and enter the forest with no mushrooms.\n\u003c/p\u003e\n\n\u003cp\u003e\nSomewhere in the forest of magic near Alice\u0027s house, lives a magician, Marisa. Marisa will steal 1 kilogram of mushrooms repeatedly from Alice until she has no more than 1 kilogram mushrooms in total. \n\u003c/p\u003e\n\n\u003cp\u003e\nSo when Alice get home, what\u0027s the maximum possible amount of mushrooms Alice has? Remember that our common sense doesn\u0027t always hold in Gensokyo. People in Gensokyo belive that 1 kilograms is equal to 1024 grams.\n\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\n\u003cp\u003e\nThere are about 8192 test cases. Process to the end of file.\n\u003c/p\u003e\n\n\u003cp\u003e\nThe first line of each test case contains an integer 0 ≤ \u003cvar\u003en\u003c/var\u003e ≤ 5, the number of mountains where Alice has picked mushrooms. The second line contains \u003cvar\u003en\u003c/var\u003e integers 0 ≤ \u003cvar\u003ew\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e ≤ 2012, the amount of mushrooms picked in each mountain.\n\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\n\u003cp\u003e\nFor each test case, output the maximum possible amount of mushrooms Alice can bring home, modulo 20121014 (this is \u003cstrong\u003eNOT\u003c/strong\u003e a prime).\n\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\n9\n4\n512 512 512 512\n5\n100 200 300 400 500\n5\n208 308 508 708 1108\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1024\n1024\n0\n792\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ch4\u003eNote\u003c/h4\u003e\n\n\u003cp\u003e\nIn the second sample, if Alice doesn\u0027t pick any mushrooms from the 5-th mountain. She can give (512+512+0)\u003d1024 grams of mushrooms to Sunny, Lunar and Star. Marisa won\u0027t steal any mushrooms from her as she has exactly 1 kilograms of mushrooms in total.\n\u003c/p\u003e\n\n\u003cp\u003e\nIn the third sample, there are no three bags whose total weight is of integral kilograms. So Alice must leave all the five bags and enter the forest with no mushrooms.\n\u003c/p\u003e\n\n\u003cp\u003e\nIn the last sample:\n\u003c/p\u003e\u003cul\u003e\n \u003cli\u003eGiving Sunny, Lunar and Star: (208+308+508)\u003d1024\u003c/li\u003e\n \u003cli\u003eStolen by Marisa: ((708+1108)-1024)\u003d792\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u003c/p\u003e\n"}}]}