#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int n, k;
double s[maxn], x, y, ans, t;
double dis(int a) { return sqrt((s[a] - x) * (s[a] - x) + y * y); }
double case1(int l, int r) { return min(dis(l), dis(r)) + s[r] - s[l]; }
double case2(int l, int r) {
  return min(dis(r) + fabs(t - s[l]), dis(l) + fabs(s[r] - t)) + s[r] - s[l];
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%lf", &s[i]);
  t = s[k];
  sort(s + 1, s + 1 + n);
  scanf("%lf %lf", &x, &y);
  if (k == n + 1)
    ans = case1(1, n);
  else {
    ans = case2(1, n);
    for (int i = 1; i < n; i++)
      ans = min(ans, min(case1(1, i) + case2(i + 1, n),
                         case1(i + 1, n) + case2(1, i)));
  }
  printf("%.7lf\n", ans);
  return 0;
}
