{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cbr\u003eAn equilateral triangle with side \u003ci\u003eN\u003c/i\u003e can be split into \u003ci\u003eN\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e unit triangles as shown on picture (a):\u003cbr\u003e\u003cimg src\u003d\"CDN_BASE_URL/dc2a946c1977870cce193a86e2a1c544?v\u003d1715982603\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\u003cbr\u003eEach unit triangle can be colored with two colors in four different ways (numbered from 1 to 4), shown on picture (b). A colored equilateral triangle with side \u003ci\u003eN\u003c/i\u003e can then be assembled from colored unit triangles in many different ways. A colored equilateral triangle is \u003ci\u003ecorrect\u003c/i\u003e if the neighboring sides of adjacent unit triangles have the same color. Such triangles form beautiful pictures like picture (c).\u003cbr\u003eYou are to find the number of different correct colored equilateral triangles that can be assembled from a given set of unit triangles. You\u0027re allowed to rotate unit triangles arbitrarily, however, the position of the big triangle is fixed (i.e., the colorings that are rotations of each other are considered different).\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/div\u003eThe first line of input contains an integer \u003ci\u003eN\u003c/i\u003e, 1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 5. The second line of input contains four non-negative integers \u003ci\u003en\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003en\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, \u003ci\u003en\u003c/i\u003e\u003csub\u003e3\u003c/sub\u003e, and \u003ci\u003en\u003c/i\u003e\u003csub\u003e4\u003c/sub\u003e, denoting the amounts of available unit triangles of kinds 1, 2, 3 and 4 respectively (as shown on picture (b)). It is always true that \u003ci\u003en\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e + \u003ci\u003en\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e + \u003ci\u003en\u003c/i\u003e\u003csub\u003e3\u003c/sub\u003e + \u003ci\u003en\u003c/i\u003e\u003csub\u003e4\u003c/sub\u003e \u003d \u003ci\u003eN\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e.\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/div\u003eOutput the sought number of correct colored equilateral triangles.\u003cbr\u003e"}},{"title":"Sample 1","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\u003e2\n0 1 0 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 2","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\u003e2\n1 1 1 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e12\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}