#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
double px[100005], py, ans, pxk;
int n, i, j, k;
double dis(int x) {
  return sqrt((px[x] - px[n + 1]) * (px[x] - px[n + 1]) + py * py);
}
double c1(int l, int r) { return abs(px[l] - px[r]) + min(dis(l), dis(r)); }
double c2(int l, int r) {
  return abs(px[l] - px[r]) +
         min(dis(l) + abs(pxk - px[r]), dis(r) + abs(pxk - px[l]));
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin >> n >> k;
  for (((i)) = (1); ((i)) <= ((n + 1)); ((i))++) {
    cin >> px[i];
  }
  cin >> py;
  pxk = px[k];
  stable_sort(px + 1, px + n + 1);
  if (k == n + 1) {
    ans = c1(1, n);
  } else {
    ans = c2(1, n);
    for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) {
      ans = min(ans, c1(1, i) + c2(i + 1, n));
      ans = min(ans, c2(1, i) + c1(i + 1, n));
    }
  }
  printf("%.18f\n", ans);
  return 0;
}
