#include <bits/stdc++.h>
using namespace std;
int n, k;
double q, a[10000005], ans, y;
double d(int l) { return sqrt((a[l] - a[n + 1]) * (a[l] - a[n + 1]) + y * y); }
double K(int l, int r) { return a[r] - a[l] + min(d(l), d(r)); }
double H(int l, int r) {
  return a[r] - a[l] + min(d(l) + fabs(q - a[r]), d(r) + fabs(q - a[l]));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n + 1; i++) scanf("%lf", &a[i]);
  scanf("%lf", &y);
  q = a[k];
  sort(a + 1, a + n + 1);
  if (k == n + 1)
    printf("%.20lf", K(1, n));
  else {
    double ans = H(1, n);
    for (int i = 1; i < n; i++)
      ans = min(ans, min(K(1, i) + H(i + 1, n), K(i + 1, n) + H(1, i)));
    printf("%.20lf", ans);
  }
  return 0;
}
