Time

13:13:31
23 May 2012
Version for print

Spiral

prb85   Numbers from 1 to N2 recorded in a square matrix of NxN in a spiral starting from the top left cell in a clockwise direction, as shown in the figure. Find a number which is located in the i-th row and j-th column.


Specifications

   Input

   In the input file the natural numbers N, i, j (1 ≤ i, j N ≤ 100).

   Output

   The output file you want to record the number that has the coordinates of i, j.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 10
Complexity: 10% 265/295

Example

Example input

5 4 2

Example output

23


← Transfer Problems Waterpipe - 2 →