## Land Acquisition

Farmer John is considering buying more land for the farm and has his eye on additional rectangular plots, each with integer dimensions .

If FJ wants to buy a single piece of land, the cost is $1/square unit, but savings are available for large purchases. He can buy any number of plots of land for a price in dollars that is the width of the widest plot times the length of the longest plot. Of course, land plots cannot be rotated, i.e., if Farmer John buys a plot and a plot in a group, he will pay .

FJ wants to grow his farm as much as possible and desires all the plots of land. Being both clever and frugal, it dawns on him that he can purchase the land in successive groups, cleverly minimizing the total cost by grouping various plots that have advantageous width or length values.

Given the number of plots for sale and the dimensions of each, determine the minimum amount for which Farmer John can purchase all

#### INPUT FORMAT:

Line : A single integer: . Lines : Line describes plot with two space-separated integers: and

#### SAMPLE INPUT:

`4 100 1 15 15 20 5 1 100`

INPUT DETAILS:

There are four plots for sale with dimensions as shown.

#### OUTPUT FORMAT:

Line 1: The minimum amount necessary to buy all the plots.

#### SAMPLE OUTPUT:

`500`

OUTPUT DETAILS:

The first group contains a plot and costs 100. The next group contains a 1x100 plot and costs 100. The last group contains both the plot and the plot and costs 300. The total cost is 500, which is minimal.

## Comments