#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k;
double a[N], y, s, ans;
inline double sqr(double x) { return x * x; }
inline double d(int x) { return sqrt(sqr(a[x] - a[n + 1]) + sqr(y)); }
inline double c1(int l, int r) { return a[r] - a[l] + min(d(l), d(r)); }
inline double c2(int l, int r) {
  return a[r] - a[l] + min(fabs(s - a[l]) + d(r), fabs(a[r] - s) + d(l));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n + 1; i++) scanf("%lf", &a[i]);
  scanf("%lf", &y);
  s = a[k];
  sort(a + 1, a + n + 1);
  if (k == n + 1) {
    printf("%.10lf\n", c1(1, n));
    return 0;
  }
  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("%.10lf\n", ans);
  return 0;
}
