#include <bits/stdc++.h>
using namespace std;
double x[100040];
double x_end, y_end;
double xk;
int n, k;
double min_double(double d1, double d2) {
  if (d1 > d2) return d2;
  return d1;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int d;
    scanf("%d", &d);
    x[i] = d;
    if (k == i) xk = x[i];
  }
  int x1, y1;
  scanf("%d %d", &x1, &y1);
  x_end = x1;
  y_end = y1;
  sort(x + 1, x + n + 1);
  if (k == n + 1) {
    printf("%.20f\n",
           min_double(sqrt(y_end * y_end + (x_end - x[1]) * (x_end - x[1])),
                      sqrt(y_end * y_end + (x_end - x[n]) * (x_end - x[n]))) +
               x[n] - x[1]);
  } else {
    int indk;
    for (int i = 1; i <= n; i++) {
      if (x[i] == xk) indk = i;
    }
    double dist = 1e90;
    for (int i = 1; i <= n; i++) {
      dist = min_double(
          dist, x[n] - x[1] + x[n] - xk + x[i] - x[1] +
                    sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)));
      dist = min_double(
          dist, x[n] - x[1] + xk - x[1] + x[n] - x[i] +
                    sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)));
    }
    for (int i = 1; i <= n - 1; i++) {
      if (indk <= i) {
        double p1 = min_double(
            xk - x[1] + x[i] - x[1] +
                sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)),
            x[i] - xk + x[i] - x[1] +
                sqrt(y_end * y_end + (x[1] - x_end) * (x[1] - x_end)));
        double p2 = min_double(
            x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[i + 1] - x_end) * (x[i + 1] - x_end)),
            x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[n] - x_end) * (x[n] - x_end)));
        dist = min_double(dist, p1 + p2);
      } else {
        double p1 = min_double(
            x[i] - x[1] + sqrt(y_end * y_end + (x[i] - x_end) * (x[i] - x_end)),
            x[i] - x[1] +
                sqrt(y_end * y_end + (x[1] - x_end) * (x[1] - x_end)));
        double p2 = min_double(
            x[n] - xk + x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[i + 1] - x_end) * (x[i + 1] - x_end)),
            xk - x[i + 1] + x[n] - x[i + 1] +
                sqrt(y_end * y_end + (x[n] - x_end) * (x[n] - x_end)));
        dist = min_double(dist, p1 + p2);
      }
    }
    printf("%.20f\n", dist);
  }
  fflush(stdin);
  getchar();
}
