#include <bits/stdc++.h>
using namespace std;
const double pi = atan(1) * 4;
int x[100005], xx, yy, xk;
int n, k, i;
double s;
int main() {
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &x[i]);
  scanf("%d%d", &xx, &yy);
  xk = x[k - 1];
  sort(x, x + n);
  if (k == n + 1)
    s = (x[n - 1] - x[0] +
         min((sqrt(1.0 * (xx - x[0]) * (xx - x[0]) + 1.0 * yy * yy)),
             (sqrt(1.0 * (xx - x[n - 1]) * (xx - x[n - 1]) + 1.0 * yy * yy))));
  else
    for (s = (x[n - 1] - x[0] +
              min((sqrt(1.0 * (xx - x[0]) * (xx - x[0]) + 1.0 * yy * yy)) +
                      abs(xk - x[n - 1]),
                  (sqrt(1.0 * (xx - x[n - 1]) * (xx - x[n - 1]) +
                        1.0 * yy * yy)) +
                      abs(xk - x[0]))),
        i = 1;
         i < n; i++)
      s = min(
          s,
          min((x[i - 1] - x[0] +
               min((sqrt(1.0 * (xx - x[0]) * (xx - x[0]) + 1.0 * yy * yy)),
                   (sqrt(1.0 * (xx - x[i - 1]) * (xx - x[i - 1]) +
                         1.0 * yy * yy)))) +
                  (x[n - 1] - x[i] +
                   min((sqrt(1.0 * (xx - x[i]) * (xx - x[i]) + 1.0 * yy * yy)) +
                           abs(xk - x[n - 1]),
                       (sqrt(1.0 * (xx - x[n - 1]) * (xx - x[n - 1]) +
                             1.0 * yy * yy)) +
                           abs(xk - x[i]))),
              (x[i - 1] - x[0] +
               min((sqrt(1.0 * (xx - x[0]) * (xx - x[0]) + 1.0 * yy * yy)) +
                       abs(xk - x[i - 1]),
                   (sqrt(1.0 * (xx - x[i - 1]) * (xx - x[i - 1]) +
                         1.0 * yy * yy)) +
                       abs(xk - x[0]))) +
                  (x[n - 1] - x[i] +
                   min((sqrt(1.0 * (xx - x[i]) * (xx - x[i]) + 1.0 * yy * yy)),
                       (sqrt(1.0 * (xx - x[n - 1]) * (xx - x[n - 1]) +
                             1.0 * yy * yy))))));
  printf("%.20f\n", s);
  return 0;
}
