#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
double y;
double num[maxn];
int n, k;
double xk;
inline double A(int z) {
  return sqrt((num[z] - num[n + 1]) * (num[z] - num[n + 1]) + y * y);
}
inline double B(int l, int r) { return num[r] - num[l] + min(A(r), A(l)); }
inline double C(int l, int r) {
  return num[r] - num[l] +
         min(abs(xk - num[l]) + A(r), abs(xk - num[r]) + A(l));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n + 1; i++) scanf("%lf", &num[i]);
  scanf("%lf", &y);
  xk = num[k];
  sort(num + 1, num + n + 1);
  if (k == n + 1)
    printf("%.20lf", B(1, n));
  else {
    double ans = C(1, n);
    for (int i = 2; i <= n; i++) {
      double t = min(B(1, i - 1) + C(i, n), C(1, i - 1) + B(i, n));
      if (t < ans) ans = t;
    }
    printf("%.20lf", ans);
  }
  return 0;
}
