If You Are Homeless... Just Build a House
Your Minecraft world looks like a grid , the cell at the intersection of the -th row and the -th column is denoted as . There are blocks on the cell .
With a cost of one coin, you can remove one block from the top of the cell, if there is at least one block there, or add one block on top. In other words, for one coin you can change any by if it doesn't become negative after.
You want to build a house the size of . To do this, you need a section of the grid of size , in which the numbers of blocks in all cells are the same. In other words, to build a house there have to exist some integers with , that all numbers for , are equal to each other.
What is the least amount of coins you need to spend to have the necessary area for your new amazing house?
Giriş verilənləri
The first line contains two integers () — the size of your Minecraft world.
The second line contains two integers (, ) — the dimensions of your future house.
The th of the next rows contains integers ().
Çıxış verilənləri
Print a single integer — the least amount of coins you have to spend to have the necessary area for your house.
Nümunələr
Qeyd
In the first sample, you can increase with coin, obtaining an area of size , on each cell of which there are exactly cubes.
In the second example, you can reduce by with coins, again obtaining an area of size , on each cell of which there are exactly cubes.