Tile Exchanging

No attempts yetTime limit1sMemory limit128 MB

Problem

Farmer John wants to redo the floor of his barn using a collection of square tiles he bought from the local square mart (which, of course, only sells square objects). Unfortunately, he didn't measure the barn correctly before buying, so now he has to exchange some of his tiles for new square tiles of different sizes.

The $N$ square tiles Farmer John already owns have side lengths $A_1, A_2, \dots, A_N$. He wants to exchange some of them for new square tiles so that the total sum of the areas of his tiles becomes exactly $M$. A tile of side length $A_i$ can be exchanged for a new tile of side length $B_i$ at a cost of $|A_i - B_i| \times |A_i - B_i|$. This offer applies only to the originally purchased tiles: a tile obtained through an exchange cannot itself be exchanged again (for example, a side-3 tile cannot be exchanged for a side-2 tile which is then exchanged for a side-1 tile).

Determine the minimum total cost needed to make the sum of the tile areas equal to $M$. If it is impossible to reach a total area of $M$, output $-1$.

Input

  • The first line contains two space-separated integers $N$ and $M$ ($1 \le N \le 10$, $1 \le M \le 10000$).
  • Each of the next $N$ lines contains one integer $A_i$, the side length of the $i$-th square tile ($1 \le A_i \le 100$).

Output

Print the minimum cost of exchanging tiles so that the total area becomes $M$, or $-1$ if this is impossible.

Hint

In the first example there are 3 tiles: two squares of side length 3 and one square of side length 1, and the goal is a total area of 6. Exchange one side-3 square for a side-1 square at a cost of $(3-1)^2 = 4$, and the other side-3 square for a side-2 square at a cost of $(3-2)^2 = 1$. The total area then becomes $1 + 4 + 1 = 6$ and the total cost is $4 + 1 = 5$.