#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010 + 1;
int n, k, x[MAXN], xx, yy;
inline long double dis(int x1, int y1, int x2, int y2) {
  return hypot((long double)x2 - x1, (long double)y2 - y1);
}
inline long double goUp(int s, int t) {
  return min(x[k] - x[s] + dis(xx, yy, x[t], 0),
             x[t] - x[k] + dis(xx, yy, x[s], 0)) +
         x[t] - x[s];
}
inline long double goDown(int s, int t) {
  return min(dis(xx, yy, x[s], 0), dis(xx, yy, x[t], 0)) + x[t] - x[s];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  scanf("%d%d", &xx, &yy);
  int xk = x[k - 1];
  sort(x, x + n);
  if (k == n + 1) {
    printf("%.15Lf\n", min(dis(xx, yy, x[0], 0), dis(xx, yy, x[n - 1], 0)) +
                           x[n - 1] - x[0]);
    return 0;
  }
  k = lower_bound(x, x + n, xk) - x;
  long double res = goUp(0, n - 1);
  for (int i = 0; i < k; i++) res = min(res, goUp(i + 1, n - 1) + goDown(0, i));
  for (int i = k + 1; i < n; i++)
    res = min(res, goUp(0, i - 1) + goDown(i, n - 1));
  printf("%.15Lf\n", res);
  return 0;
}
