#include <bits/stdc++.h>
using namespace std;
vector<float> ax(100010, 0);
long int n, k;
float xx, yc;
float dist(float x) {
  return (sqrt((ax[n + 1] - x) * (ax[n + 1] - x) + yc * yc));
};
float min(float x, float y) { return x < y ? x : y; };
float solve() {
  float res;
  res = ax[n] - ax[1] + min(dist(ax[1]), dist(ax[n]));
  if (k == n + 1) return res;
  for (long int i = 1; i <= n; i++)
    if (ceil(ax[i]) == xx) {
      k = i;
      break;
    }
  res += dist(ax[k]);
  for (long int i = 2; i <= k; i++) {
    res = min(res, 2 * (ax[n] - ax[k]) + ax[k] - ax[i] + dist(ax[i]) +
                       min(dist(ax[1]), dist(ax[i - 1])) + ax[i - 1] - ax[1]);
    res = min(res, 2 * (ax[k] - ax[i]) + ax[n] - ax[k] + dist(ax[n]) +
                       min(dist(ax[1]), dist(ax[i - 1])) + ax[i - 1] - ax[1]);
  }
  for (long int i = n - 1; i >= k; i--) {
    res = min(res, 2 * (ax[k] - ax[1]) + ax[i] - ax[k] + dist(ax[i]) +
                       min(dist(ax[n]), dist(ax[i + 1])) + ax[n] - ax[i + 1]);
    res = min(res, 2 * (ax[i] - ax[k]) + ax[k] - ax[1] + dist(ax[1]) +
                       min(dist(ax[n]), dist(ax[i + 1])) + ax[n] - ax[i + 1]);
  }
  res = min(res,
            ax[n] - ax[1] +
                min(dist(ax[1]) + ax[n] - ax[k], dist(ax[n]) + ax[k] - ax[1]));
  return res;
};
int main() {
  FILE *fin, *fout;
  scanf("%d%d", &n, &k);
  for (long int i = 1; i <= n + 1; i++) scanf("%f", &ax[i]);
  scanf("%f", &yc);
  xx = ax[k];
  sort(ax.begin() + 1, ax.begin() + n + 1);
  printf("%f", solve());
}
