Description
Brother Er like eating meat very much. One day, he found a street full of meat. There are n room in the street. In each room there are ai unit of meat. When Brother Er in room i, he can get room i-1 or room i+1 (if exist) and use 1 unit of time. And if Brother Er eat one unit of meat ,he need one unit of time.Brother Er is very Hunger and want to eat all the meat with minimum time. First Brother Er is in room x. And he can stay at any room when he eat all the meat. Can you tell me the minimum time ?
Input
There are multiple test cases in the input file.
In each case the first line contains 2 integers n (2<=n<=100) — the number of room, x (1<=x<=n) - the initial room of Brother Er.
The second line contains n distinct space-separated integers a1, a2, ..., an (0<=ai<=1000) — the number of meat in each room.
Output
For each case print a single line with the minimum time.