F. Flipping Pyramid
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In the ancient land of Tetralia, a magical pyramid roams the infinite two-dimensional triangle grid. This pyramid is a regular tetrahedron (a triangular pyramid where all four faces are congruent equilateral triangles). Each of its four faces has a positive integer $$$a,b,c,d$$$ marked on it.

Initially, the pyramid stands upright at coordinate $$$(0,0)$$$, with one face with integer $$$a$$$ resting on the ground. The face with integer $$$b$$$ is facing toward the northwest, the face with integer $$$c$$$ is facing toward the northeast, and the face with integer $$$d$$$ is facing toward the south, as shown in the middle figure.

The infinite two-dimensional triangle grid and its coordinate $$$(x,y)$$$ is defined as the right figure, with the blue cell at $$$(0,0)$$$ i.e., the starting cell. The $$$+x$$$ direction is north, and the $$$+y$$$ direction is east.

The pyramid can move by flipping itself over one of the three edges of its bottom face; the edge that is used for flipping is called a pivot edge. After a flip, the pyramid lands on the new adjacent cell in the triangle grid, with the new face that contains the pivot edge as one of its sides resting on the ground. The cost of such a move is equal to the number marked on the new bottom face (the face touching the ground after the flip).

Your task is to find the minimum total cost to move the pyramid to the destination cell $$$(x,y)$$$.

Input

The first line contains $$$4$$$ integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^6$$$) — four faces of the pyramid.

The second line contains $$$2$$$ integers $$$x, y$$$ ($$$-10^9 \le x, y \le 10^9$$$) — the coordinates of the destination cell.

Output

A single integer — the minimum cost to move the pyramid to the destination cell.

Examples
Input
1 2 3 4
1 2
Output
15
Input
1 2 3 4
-1 0
Output
6
Input
10 10 10 10
0 0
Output
0
Note

In the first test case, the image below shows one of the moves that results in the minimum cost.

The bottom face of the tetrahedron along the path is $$$a \rightarrow c \rightarrow d \rightarrow b \rightarrow c \rightarrow a \rightarrow b$$$, resulting in the total cost of $$$3 + 4 + 2 + 3 + 1 + 2 = 15$$$.