Space Invaders#601

Space Invaders

1 second
64 megabytes
Very easy

Peter has created his own version of the well-known game "Space Invaders". In this game, alien ships attack the Earth, lining up in rows at the top of the screen. The player controls a laser gun located at the bottom of the screen in one of the columns. In each turn, the player can move the gun left or right, or fire a vertical shot upward. If the player fires, the shot destroys the closest alien ship in the column where the gun is currently positioned.

Unlike the original game, in Peter's version, the alien ships remain stationary and cannot shoot, so the player cannot lose. Help Peter destroy all the alien ships using the minimum number of moves.

Input

The first line contains and — the number of columns and the initial column number where the gun is positioned (1 \leq n \leq 100, 1 \leq p \leq n). The second line contains numbers: a_1, a_2, \ldots, a_n, where a_i is the number of aliens in the -th column (1 \leq a_i \leq 100).

Output

Output a single number — the minimum number of moves required to destroy all the alien ships.

Examples

Example 1

Loading
Loading