#include <bits/stdc++.h>
using namespace std;
const int t = 100005;
int a[t];
double l[t];
long long sqr(long long a) { return a * a; }
double cmin(double &a, double b) {
  if (b < a) a = b;
}
double ans1(int x, int y) { return a[y] - a[x] + min(l[y], l[x]); }
double ans2(int i, int x, int y) {
  return a[y] - a[x] + min(abs(i - a[x]) + l[y], abs(i - a[y]) + l[x]);
}
int main() {
  int n, k, i, x;
  double ans;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n + 2; i++) scanf("%d", a + i);
  x = a[k - 1];
  sort(a, a + n);
  for (i = 0; i < n; i++) l[i] = sqrt(sqr(a[n + 1]) + sqr(a[n] - a[i]));
  if (k == n + 1) {
    printf("%.10lf\n", ans1(0, n - 1));
  } else {
    ans = ans2(x, 0, n - 1);
    for (i = 1; i < n; i++)
      cmin(ans, min(ans1(0, i - 1) + ans2(x, i, n - 1),
                    ans2(x, 0, i - 1) + ans1(i, n - 1)));
    printf("%.10lf\n", ans);
  }
  return 0;
}
