{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThere are three machines on the new toy factory: A, B and C. The factory makes\r\ntoys by processing each toy on these machines in order A, B, C. Your task\r\nis to create \u003ci\u003eN\u003c/i\u003e toys as soon as possible. You know the time to process\r\neach toy on each machine: \u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003ec\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e. You can select\r\nan arbitrary order of processing toys. The second machine is so fast that at least one of the following two statements\r\nholds: max(\u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e)\u0026nbsp;≤\u0026nbsp;min(\u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e) or max(\u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e)\u0026nbsp;≤\u0026nbsp;min(\u003ci\u003ec\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e).\r\n\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line of the input contains the number of toys \u003ci\u003eN\u003c/i\u003e (1\u0026nbsp;≤\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;≤\u0026nbsp;10\u003csup\u003e5\u003c/sup\u003e). The next\r\n\u003ci\u003eN\u003c/i\u003e lines contain three integers each: \u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003ec\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e\r\n(1\u0026nbsp;≤\u0026nbsp;\u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003eb\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003ec\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e\u0026nbsp;≤\u0026nbsp;10\u003csup\u003e6\u003c/sup\u003e).\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOutput the minimal possible processing time on the first line.\r\nThe second line must contain an example of optimal processing order\u0026nbsp;—\r\na permutation of toy numbers from 1 to \u003ci\u003eN\u003c/i\u003e.\r\n\u003c/div\u003e\u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e5\r\n3 1 6\r\n1 1 2\r\n5 2 5\r\n7 1 4\r\n10 2 8\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e33\r\n2 1 3 5 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr\u003e\u003ctable class\u003d\u0027vjudge_sample\u0027\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\r\n5 4 7\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e16\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}