#include <bits/stdc++.h>
using namespace std;
double x[111111];
double X, Y;
int n, k;
double dist(int i) { return hypot(x[i] - X, Y); }
double solve(int l, int r) {
  if (l > r) return 0;
  return min(dist(l), dist(r)) + x[r] - x[l];
}
int main() {
  cin >> n >> k;
  --k;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  cin >> X >> Y;
  double ans = 1e9;
  if (k == n) {
    sort(x, x + n);
    ans = solve(0, n - 1);
    return printf("%.9f\n", ans), 0;
  }
  k = x[k];
  sort(x, x + n);
  k = lower_bound(x, x + n, k) - x;
  for (int l = 1; l < n; ++l) {
    for (int r = n - 1; r < n; ++r) {
      if (l <= k && k <= r) {
        int rl = 0, rr = l - 1;
        double a = x[k] - x[l], b = x[r] - x[k], t;
        t = 2 * b + a + dist(l) + solve(rl, rr);
        ans = min(ans, t);
        t = 2 * a + b + dist(r) + solve(rl, rr);
        ans = min(ans, t);
      }
    }
  }
  for (int r = 0; r < n; ++r) {
    if (k <= r) {
      int rl = r + 1, rr = n - 1;
      double a = x[k] - x[0], b = x[r] - x[k], t;
      t = 2 * b + a + dist(0) + solve(rl, rr);
      ans = min(ans, t);
      t = 2 * a + b + dist(r) + solve(rl, rr);
      ans = min(ans, t);
    }
  }
  printf("%.9f\n", ans);
  return 0;
}
