#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 5;
int n, start, y;
int x[maxN];
double res;
inline double dis(int a1, int a2) {
  return sqrt(pow((long double)x[a1] - x[a2], 2) + (long double)y * y);
}
int main() {
  scanf("%d%d", &n, &start);
  for (int i = 1; i <= n + 1; i++) scanf("%d", &x[i]);
  scanf("%d", &y);
  int fir = (start != (n + 1)) ? x[start] : 1000 * 1000 * 10;
  sort(x + 1, x + n + 1);
  if (fir == 1000 * 1000 * 10) {
    res = (x[n] - x[1]) + min(dis(1, n + 1), dis(n, n + 1));
    printf("%.10lf\n", res);
    return 0;
  }
  fir = lower_bound(x + 1, x + n + 1, fir) - x;
  if (y == 0) {
    int mini = min(x[1], x[n + 1]);
    int maxi = max(x[n], x[n + 1]);
    res = min(x[fir] - mini, maxi - x[fir]) + maxi - mini;
    printf("%.10lf\n", res);
    return 0;
  }
  double res =
      dis(fir, n + 1) + min(dis(n + 1, 1), dis(n + 1, n)) + (x[n] - x[1]);
  res = min(res,
            min(x[n] - x[fir] + dis(1, n + 1), x[fir] - x[1] + dis(n, n + 1)) +
                (x[n] - x[1]));
  res = min(res, x[fir] - x[1] + dis(1, n + 1) +
                     ((fir != n) ? min(dis(fir + 1, n + 1), dis(n, n + 1)) +
                                       x[n] - x[fir + 1]
                                 : 0));
  for (int i = 2; i < fir; i++) {
    res = min(res, x[n] - x[i] +
                       min(dis(n, n + 1) + x[fir] - x[i],
                           dis(i, n + 1) + x[n] - x[fir]) +
                       min(dis(i - 1, n + 1), dis(1, n + 1)) + x[i - 1] - x[1]);
  }
  for (int i = fir + 1; i < n; i++) {
    res = min(res, x[i] - x[1] +
                       min(dis(1, n + 1) + x[i] - x[fir],
                           dis(i, n + 1) + x[fir] - x[1]) +
                       min(dis(i + 1, n + 1), dis(n, n + 1)) + x[n] - x[i + 1]);
  }
  res = min(res, x[n] - x[fir] + dis(n, n + 1) +
                     ((fir != 1) ? min(dis(fir - 1, n + 1), dis(1, n + 1)) +
                                       x[fir - 1] - x[1]
                                 : 0));
  printf("%.10lf\n", res);
  return 0;
}
