#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const double INF = 1.2676506e+30;
double x[MAXN], s[MAXN], xi, yi;
int n, k;
double dist(int i) {
  if (i < 0 || i >= n) return 0;
  return sqrt((x[i] - xi) * (x[i] - xi) + yi * yi);
}
double dist(int i, int j) {
  if (i >= j) return 0;
  return s[j] - s[i];
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%lf", x + i);
  scanf("%lf %lf", &xi, &yi);
  if (n == 1) {
    printf("%.20lf\n", dist(0));
    return 0;
  }
  int tx = x[k - 1];
  sort(x, x + n);
  if (k != n + 1) {
    for (int i = 0; i < n; ++i) {
      if (x[i] == tx) {
        k = i;
        break;
      }
    }
  }
  s[0] = 0.0;
  for (int i = 1; i < n; ++i) s[i] = s[i - 1] + x[i] - x[i - 1];
  if (k == n + 1) {
    double ans = INF;
    for (int i = 0; i < n; ++i) {
      double cur = dist(i);
      cur += min(dist(i, n - 1) + dist(0, n - 1), dist(0, i) + dist(0, n - 1));
      if (ans > cur) ans = cur;
    }
    printf("%.20lf\n", ans);
  } else {
    double ans = INF;
    for (int i = 0; i <= k; ++i) {
      double cur1 = dist(i, k) + dist(i, n - 1) + dist(n - 1) +
                    min(dist(0) + dist(0, i - 1), dist(i - 1) + dist(0, i - 1));
      double cur2 = dist(k, n - 1) + dist(i, n - 1) + dist(i) +
                    min(dist(0) + dist(0, i - 1), dist(i - 1) + dist(0, i - 1));
      ans = min(min(cur1, cur2), ans);
    }
    for (int i = k; i < n; ++i) {
      double cur1 = dist(k, i) + dist(0, i) + dist(0) +
                    min(dist(n - 1) + dist(i + 1, n - 1),
                        dist(i + 1) + dist(i + 1, n - 1));
      double cur2 = dist(0, k) + dist(0, i) + dist(i) +
                    min(dist(n - 1) + dist(i + 1, n - 1),
                        dist(i + 1) + dist(i + 1, n - 1));
      ans = min(min(cur1, cur2), ans);
    }
    printf("%.20lf\n", ans);
  }
  return 0;
}
