#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int DIM = 110 * 1000;
int n, k;
int x[DIM], y;
double ans = 0.0;
double sqr(double q) { return q * q; }
double dist(int i, int j) {
  double y1 = 0.0, y2 = 0.0;
  if (i == n) y1 = y;
  if (j == n) y2 = y;
  return sqrt(sqr(x[i] - x[j]) + sqr(y1 - y2));
}
int main() {
  scanf("%d%d", &n, &k);
  k--;
  for (int i = (0); i < (n + 1); i++) scanf("%d", &x[i]);
  scanf("%d", &y);
  int xold;
  if (k < n) xold = x[k];
  sort(x, x + n);
  if (k < n) {
    for (int i = (0); i < (n); i++)
      if (xold == x[i]) {
        k = i;
        break;
      }
  }
  ans = 1e30;
  if (k == n) {
    ans = min(ans, dist(n, 0) + dist(0, n - 1));
    ans = min(ans, dist(n, n - 1) + dist(n - 1, 0));
  } else {
    ans = min(ans, dist(k, n) + dist(n, 0) + dist(0, n - 1));
    ans = min(ans, dist(k, n) + dist(n, n - 1) + dist(n - 1, 0));
    for (int j = (k); j < (n); j++) {
      double cand = 0.0;
      cand = dist(k, 0) + dist(0, j) + dist(j, n);
      if (j + 1 < n)
        cand += min(dist(n, j + 1) + dist(j + 1, n - 1),
                    dist(n, n - 1) + dist(n - 1, j + 1));
      ans = min(ans, cand);
      cand = dist(k, j) + dist(j, 0) + dist(0, n);
      if (j + 1 < n)
        cand += min(dist(n, j + 1) + dist(j + 1, n - 1),
                    dist(n, n - 1) + dist(n - 1, j + 1));
      ans = min(ans, cand);
    }
    for (int j = (0); j < (k + 1); j++) {
      double cand = 0.0;
      cand = dist(k, n - 1) + dist(n - 1, j) + dist(j, n);
      if (j - 1 >= 0)
        cand +=
            min(dist(n, j - 1) + dist(j - 1, 0), dist(n, 0) + dist(0, j - 1));
      ans = min(ans, cand);
      cand = 0.0;
      cand = dist(k, j) + dist(j, n - 1) + dist(n - 1, n);
      if (j - 1 >= 0)
        cand +=
            min(dist(n, j - 1) + dist(j - 1, 0), dist(n, 0) + dist(0, j - 1));
      ans = min(ans, cand);
    }
  }
  printf("%.8lf\n", ans);
  return 0;
}
