#include <bits/stdc++.h>
using namespace std;
double x[100010], y, ans, newtag;
int n, k;
double len(int i) {
  if (i <= 0) return 0;
  double dx = x[n + 1] - x[i], dy = y;
  return sqrt(dx * dx + dy * dy);
}
double ll(int i) {
  double xi = newtag;
  double xj = x[i];
  if (xj < xi) {
    int tmp = xi;
    xi = xj;
    xj = tmp;
  }
  return xj - xi;
}
double calc1(int l, int r) { return x[r] - x[l] + min(len(l), len(r)); }
double calc2(int l, int r) {
  return x[r] - x[l] + min(len(l) + ll(r), len(r) + ll(l));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n + 1; i++) scanf("%lf", &x[i]);
  scanf("%lf", &y);
  newtag = x[k];
  sort(x + 1, x + n + 1);
  if (k == n + 1) {
    ans = calc1(1, n);
  } else {
    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("%.101lf\n", ans);
  return 0;
}
