Problem: Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.

King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordinate system on it. Every city is a point on this plane. There are n cities in the kingdom at points with coordinates (x1, 0), (x2, 0), ..., (xn, 0), and there is one city at point (xn + 1, yn + 1). 

King starts his journey in the city number k. Your task is to find such route for the king, which visits all cities (in any order) and has minimum possible length. It is allowed to visit a city twice. The king can end his journey in any city. Between any pair of cities there is a direct road with length equal to the distance between the corresponding points. No two cities may be located at the same point.

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n + 1) — amount of cities and index of the starting city. The second line contains n + 1 numbers xi. The third line contains yn + 1. All coordinates are integers and do not exceed 106 by absolute value. No two cities coincide.

Output

Output the minimum possible length of the journey. Your answer must have relative or absolute error less than 10 - 6.

Examples

Input

3 1
0 1 2 1
1


Output

3.41421356237309490000

Input

3 1
1 0 2 1
1


Output

3.82842712474619030000

Input

4 5
0 5 -1 -5 2
3


Output

14.24264068711928400000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
double x[100040];
double x_end, y_end;
double xk;
int n, k;
double min_double(double d1, double d2) {
  if (d1 > d2) return d2;
  return d1;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int d;
    scanf("%d", &d);
    x[i] = d;
    if (k == i) xk = x[i];
  }
  int x1, y1;
  scanf("%d %d", &x1, &y1);
  x_end = x1;
  y_end = y1;
  sort(x + 1, x + n + 1);
  if (k == n + 1) {
    printf("%.20f\n",
           min_double(sqrt(y_end * y_end + (x_end - x[1]) * (x_end - x[1])),
                      sqrt(y_end * y_end + (x_end - x[n]) * (x_end - x[n]))) +
               x[n] - x[1]);
  } else {
    int indk;
    for (int i = 1; i <= n; i++) {
      if (x[i] == xk) indk = i;
    }
    double dist = 1e90;
    for (int i = 1; i <= n; i++) {
      dist = min_double(
          dist, x[n] - x[1] + x[n] - xk + x[i] - x[1] +
                    sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)));
      dist = min_double(
          dist, x[n] - x[1] + xk - x[1] + x[n] - x[i] +
                    sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)));
    }
    for (int i = 1; i <= n - 1; i++) {
      if (indk <= i) {
        double p1 = min_double(
            xk - x[1] + x[i] - x[1] +
                sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)),
            x[i] - xk + x[i] - x[1] +
                sqrt(y_end * y_end + (x[1] - x_end) * (x[1] - x_end)));
        double p2 = min_double(
            x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[i + 1] - x_end) * (x[i + 1] - x_end)),
            x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[n] - x_end) * (x[n] - x_end)));
        dist = min_double(dist, p1 + p2);
      } else {
        double p1 = min_double(
            x[i] - x[1] + sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)),
            x[i] - x[1] +
                sqrt(y_end * y_end + (x[1] - x_end) * (x[1] - x_end)));
        double p2 = min_double(
            x[n] - xk + x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[i + 1] - x_end) * (x[i + 1] - x_end)),
            xk - x[i + 1] + x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[n] - x_end) * (x[n] - x_end)));
        dist = min_double(dist, p1 + p2);
      }
    }
    printf("%.20f\n", dist);
  }
  fflush(stdin);
  getchar();
}