#include <bits/stdc++.h>
using namespace std;
int n, k;
double sx;
double xx[100100];
double ans;
double y;
double dis(int l) {
  return sqrt((xx[l] - xx[n + 1]) * (xx[l] - xx[n + 1]) + y * y);
}
double to[100100];
double c1(int l, int r) { return xx[r] - xx[l] + min(dis(l), dis(r)); }
double c2(int l, int r) {
  return xx[r] - xx[l] +
         min(dis(l) + fabs(sx - xx[r]), dis(r) + fabs(sx - xx[l]));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n + 1; i++) {
    int x;
    scanf("%lf", &xx[i]);
  }
  scanf("%lf", &y);
  sx = xx[k];
  sort(xx + 1, xx + n + 1);
  if (k == n + 1) {
    double ans = c1(1, n);
    printf("%.12lf", ans);
  } else {
    double ans = c2(1, n);
    for (int i = 1; i < n; i++) {
      ans = min(ans, min(c1(1, i) + c2(i + 1, n), c2(1, i) + c1(i + 1, n)));
    }
    printf("%.12lf", ans);
  }
  return 0;
}
