#include <bits/stdc++.h>
using namespace std;
int n, k;
double x[100008], y, mx;
struct Tprogram {
  void open() {
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
  }
  void close() {}
  void init() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n + 1; i++) scanf("%lf", &x[i]);
    mx = x[k];
    sort(x + 1, x + n + 1);
    scanf("%lf", &y);
  }
  double dis(int l) {
    return sqrt((x[n + 1] - x[l]) * (x[n + 1] - x[l]) + y * y);
  }
  double get(int l, int r) {
    if (r < l) return 0;
    return (dis(l) < dis(r) ? dis(l) : dis(r)) + x[r] - x[l];
  }
  double make(int l, int r) {
    return (fabs(mx - x[l]) + dis(r) < fabs(mx - x[r]) + dis(l)
                ? fabs(mx - x[l]) + dis(r)
                : fabs(mx - x[r]) + dis(l)) +
           x[r] - x[l];
  }
  void work() {
    if (k == n + 1) {
      printf("%.10lf\n", get(1, n));
    } else {
      double ans = 1e9;
      for (int i = 1; i <= n; i++) {
        ans = (ans < make(1, i) + get(i + 1, n) ? ans
                                                : make(1, i) + get(i + 1, n));
        ans = (ans < make(i, n) + get(1, i - 1) ? ans
                                                : make(i, n) + get(1, i - 1));
      }
      printf("%.10lf\n", ans);
    }
  }
} Program;
int main() {
  Program.init();
  Program.work();
  return 0;
}
