Triangle#8507

Triangle

1 second
256 megabytes
Easy

An equilateral triangle with side can be split into n^2 unit triangles as shown on picture (a):

prb8507.gif

Each unit triangle can be colored in four different ways (numbered from to ), shown on picture (b). A colored equilateral triangle with side can then be assembled from colored unit triangles in many different ways. A colored equilateral triangle is correct if the neighboring sides of adjacent unit triangles have the same color. Such triangles form beautiful pictures like picture (c).

You are to find the number of different correct colored equilateral triangles that can be assembled from a given set of unit triangles. You're 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).

Input

The first line contains an integer (1 \le n \le 5). The second line contains four non-negative integers n_1, n_2, n_3 and n_4, denoting the amounts of available unit triangles of kinds , , and respectively (as shown on picture (b)). It is always true that n_1 + n_2 + n_3 + n_4 = n^2.

Output

Output the sought number of correct colored equilateral triangles.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading