#include <bits/stdc++.h>
using namespace std;
const int MAX_N = int(1e5) + 10;
int n, m;
double data[MAX_N];
double st, x, y, ans;
double dist(int p) {
  double dx = x - data[p];
  double dy = y;
  return sqrt(dx * dx + dy * dy);
}
double f(int l, int r) {
  double res = data[r] - data[l];
  return res + min(dist(l), dist(r));
}
double g(int l, int r) {
  double res = data[r] - data[l];
  res += min(dist(l) + fabs(st - data[r]), dist(r) + fabs(st - data[l]));
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%lf", data + i);
  scanf("%lf%lf", &x, &y);
  st = data[m - 1];
  sort(data, data + n);
  if (m > n)
    ans = f(0, n - 1);
  else {
    ans = g(0, n - 1);
    for (int i = 1; i < n; ++i) {
      double tmp = min(f(0, i - 1) + g(i, n - 1), g(0, i - 1) + f(i, n - 1));
      ans = min(ans, tmp);
    }
  }
  printf("%.9lf\n", ans);
  return 0;
}
