#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const double eps = 1e-14;
const double pi = acos(-1.0);
int n, k;
double pos, ans, y;
double xx[maxn];
double cal(int l) {
  return sqrt((xx[l] - xx[n + 1]) * (xx[l] - xx[n + 1]) + y * y);
}
double dis[maxn];
double to[maxn];
double calc1(int l, int r) { return xx[r] - xx[l] + min(cal(l), cal(r)); }
double calc2(int l, int r) {
  return xx[r] - xx[l] +
         min(cal(l) + fabs(pos - xx[r]), cal(r) + fabs(pos - xx[l]));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n + 1; i++) scanf("%lf", &xx[i]);
  scanf("%lf", &y);
  pos = xx[k];
  sort(xx + 1, xx + n + 1);
  if (k == n + 1) {
    double ans = calc1(1, n);
    printf("%.12f\n", ans);
  } else {
    double ans = calc2(1, n);
    for (int i = 1; i < n; i++) {
      ans = min(ans, min(calc1(1, i) + calc2(i + 1, n),
                         calc2(1, i) + calc1(i + 1, n)));
    }
    printf("%.12f\n", ans);
  }
  return 0;
}
