#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
int N, K;
int _x[200000];
double x[200000], xp, yp, ans;
template <class T>
inline T sqr(T x) {
  return x * x;
}
struct point {
  double x, y;
  point() {}
  point(double _x, double _y) : x(_x), y(_y) {}
};
inline double dis(const point &a, const point &b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
int main() {
  scanf("%d%d", &N, &K);
  int flag = (K == N + 1);
  for (int i = (1); i <= (N); ++i) scanf("%d", &_x[i]);
  int target = _x[K];
  sort(_x + 1, _x + N + 1);
  N = unique(_x + 1, _x + N + 1) - _x - 1;
  for (int i = (1); i <= (N); ++i)
    if (_x[i] == target) K = i;
  for (int i = (1); i <= (N); ++i) x[i] = _x[i];
  scanf("%lf%lf", &xp, &yp);
  if (N == 1) {
    ans = dis(point(xp, yp), point(x[1], 0));
  } else if (flag) {
    ans = x[N] - x[1] +
          min(sqrt(sqr(yp) + sqr(xp - x[1])), sqrt(sqr(yp) + sqr(xp - x[N])));
  } else {
    ans = 1e30;
    point a = point(x[K], 0);
    point b = point(x[1], 0);
    point c = point(x[N], 0);
    point d = point(xp, yp);
    ans = min(ans, dis(a, b) + dis(b, c) + dis(c, d));
    ans = min(ans, dis(a, b) + dis(b, d) + dis(d, c) +
                       (K != N) * dis(c, point(x[K + 1], 0)));
    ans = min(ans, dis(a, c) + dis(c, b) + dis(b, d));
    ans = min(ans, dis(a, c) + dis(c, d) + dis(d, b) +
                       (K != 1) * dis(point(x[K - 1], 0), b));
    if (K != 1)
      ans = min(ans, dis(a, c) + dis(c, d) + dis(d, point(x[K - 1], 0)) +
                         x[K - 1] - x[1]);
    if (K != N)
      ans = min(ans, dis(a, b) + dis(b, d) + dis(d, point(x[K + 1], 0)) + x[N] -
                         x[K + 1]);
    ans = min(ans, dis(a, d) + dis(d, b) + dis(b, c));
    ans = min(ans, dis(a, d) + dis(d, c) + dis(c, b));
    if (K == N) {
      ans = min(ans, dis(a, d) + dis(d, point(x[K - 1], 0)) +
                         dis(point(x[K - 1], 0), b));
      for (int i = (1); i <= (N); ++i) {
        ans = min(ans, x[N] - x[i] + dis(point(x[i], 0), d) +
                           dis(d, point(x[i - 1], 0)) + x[i - 1] - x[1]);
      }
    }
    if (K == 1) {
      ans = min(ans, dis(a, d) + dis(d, point(x[K + 1], 0)) +
                         dis(point(x[K + 1], 0), c));
      for (int i = (1); i <= (N); ++i) {
        ans = min(ans, x[i] - x[1] + dis(point(x[i], 0), d) +
                           dis(d, point(x[i + 1], 0)) + x[N] - x[i + 1]);
      }
    }
    if (x[K] >= xp) {
      for (int t = (1); t <= (N); ++t) {
        double ret = 0;
        ret += 2 * dis(point(x[K], 0), c);
        ret += abs(x[K] - x[t]);
        ret += dis(point(x[t], 0), d);
        if (t - 1 > 0) ret += dis(d, point(x[t - 1], 0));
        if (t - 2 > 0) ret += abs(x[t - 1] - x[1]);
        ans = min(ans, ret);
        ret = 0;
        ret += 2 * abs(x[K] - x[t]);
        ret += abs(x[N] - x[K]);
        ret += dis(c, d);
        if (t - 1 > 0) ret += dis(d, point(x[t - 1], 0));
        if (t - 2 > 0) ret += abs(x[t - 1] - x[1]);
        ans = min(ans, ret);
      }
    } else {
      for (int t = (1); t <= (N); ++t) {
        double ret = 0;
        ret += 2 * dis(point(x[K], 0), b);
        ret += abs(x[t] - x[K]);
        ret += dis(point(x[t], 0), d);
        if (t + 1 <= N) ret += dis(d, point(x[t + 1], 0));
        if (t + 2 <= N) ret += abs(x[N] - x[t + 1]);
        ans = min(ans, ret);
        ret = 0;
        ret += 2 * abs(x[t] - x[K]);
        ret += abs(x[K] - x[1]);
        ret += dis(b, d);
        if (t + 1 <= N) ret += dis(d, point(x[t + 1], 0));
        if (t + 2 <= N) ret += abs(x[N] - x[t + 1]);
        ans = min(ans, ret);
      }
    }
    for (int t = (K + 1); t <= (N); ++t) {
      double ret = 0;
      ret += 2 * (x[t] - x[K]);
      ret += x[K] - x[1];
      ret += dis(b, d);
      ret += dis(d, c);
      ret += x[N] - x[t + 1];
      ans = min(ans, ret);
      ret = 0;
      ret += 2 * (x[t] - x[K]);
      ret += x[K] - x[1];
      ret += dis(b, d);
      ret += dis(d, point(x[t + 1], 0));
      ret += x[N] - x[t + 1];
      ans = min(ans, ret);
    }
    for (int t = (1); t <= (K - 1); ++t) {
      double ret = 0;
      ret += 2 * (x[K] - x[t]);
      ret += x[N] - x[K];
      ret += dis(b, d);
      ret += dis(d, c);
      ret += x[t - 1] - x[1];
      ans = min(ans, ret);
      ret = 0;
      ret += 2 * (x[K] - x[t]);
      ret += x[N] - x[K];
      ret += dis(point(x[1], 0), d);
      ret += dis(d, c);
      ret += x[t - 1] - x[1];
      ans = min(ans, ret);
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}
