#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int inf = 0x3f3f3f3f;
int n, k;
double x[maxn], y;
double stx, sty;
void input() {
  cin >> n >> k;
  for (register int i = 1; i <= n + 1; i++) cin >> x[i];
  cin >> y;
  stx = x[k], sty = ((k == n + 1) ? y : 0);
}
double dis(double x1, double y1, double x2, double y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
double A(int l, int r) {
  return x[r] - x[l] +
         min(dis(x[l], 0, x[n + 1], y), dis(x[r], 0, x[n + 1], y));
}
double B(int l, int r) {
  return x[r] - x[l] +
         min(abs(stx - x[l]) + dis(x[r], 0, x[n + 1], y),
             abs(stx - x[r]) + dis(x[l], 0, x[n + 1], y));
}
void solve() {
  double ans = inf;
  sort(x + 1, x + n + 1);
  if (k == n + 1) {
    ans = min(dis(x[n + 1], y, x[1], 0), dis(x[n + 1], y, x[n], 0));
    ans += x[n] - x[1];
    printf("%.20f\n", (double)ans);
  } else {
    ans = B(1, n);
    for (register int i = 2; i <= n; i++) {
      ans = min(ans, min(A(1, i - 1) + B(i, n), A(i, n) + B(1, i - 1)));
    }
    printf("%.20f\n", (double)ans);
  }
}
int main() {
  input();
  solve();
  return 0;
}
