#include <bits/stdc++.h>
using namespace std;
int a[100010], n, k, x, y, now;
double ans;
double dis(int z) {
  return sqrt((double)(x - z) * (double)(x - z) + (double)(y) * (double)(y));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d%d", &x, &y);
  now = a[k];
  sort(a + 1, a + n + 1);
  if (k == n + 1) {
    ans = a[n] - a[1] + min(dis(a[1]), dis(a[n]));
    printf("%.8lf\n", ans);
    exit(0);
  }
  ans = a[n] - a[1] +
        min(dis(a[n]) + abs(now - a[1]), dis(a[1]) + abs(now - a[n]));
  for (int i = 1; i <= n; i++) {
    if (i > 1)
      ans = min(ans, a[i - 1] - a[1] +
                         min(dis(a[i - 1]) + abs(now - a[1]),
                             dis(a[1]) + abs(now - a[i - 1])) +
                         a[n] - a[i] + min(dis(a[i]), dis(a[n])));
    if (i < n)
      ans = min(ans, a[i] - a[1] + min(dis(a[1]), dis(a[i])) + a[n] - a[i + 1] +
                         min(dis(a[n]) + abs(now - a[i + 1]),
                             dis(a[i + 1]) + abs(now - a[n])));
  }
  printf("%.8lf\n", ans);
  return 0;
}
