#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
int n, k;
double X, Y, pos;
double x[MAXN];
double ans;
double getDis(double x1, double y1, double x2, double y2) {
  return sqrt((double)((long long)(x1 - x2) * (long long)(x1 - x2) +
                       (long long)(y1 - y2) * (long long)(y1 - y2)));
}
double cal1(int l, int r) {
  return min(getDis(x[l], 0, X, Y), getDis(x[r], 0, X, Y)) + x[r] - x[l];
}
double cal2(int l, int r) {
  return x[r] - x[l] +
         min(getDis(x[l], 0, X, Y) + fabs(pos - x[r]),
             getDis(x[r], 0, X, Y) + fabs(pos - x[l]));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%lf", &x[i]);
  pos = x[k];
  sort(x + 1, x + 1 + n);
  scanf("%lf%lf", &X, &Y);
  if (k == n + 1) {
    ans = cal1(1, n);
    printf("%.10lf\n", ans);
    return 0;
  }
  ans = cal2(1, n);
  for (int i = 1; i < n; i++)
    ans =
        min(ans, min(cal1(1, i) + cal2(i + 1, n), cal1(i + 1, n) + cal2(1, i)));
  printf("%.10lf\n", ans);
  return 0;
}
