#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
pair<int, int> coo[110000];
double dist(double x, double y) { return sqrt(x * x + y * y); }
double di(int x, int y, int i) { return dist(x - coo[i].first, y); }
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = (0); i < (N); i++) {
    scanf("%d", &(coo[i].first));
    coo[i].second = i;
  }
  sort(coo, coo + N);
  int x, y;
  scanf("%d%d", &x, &y);
  --K;
  double res = 1e10;
  if (K == N) {
    res = coo[N - 1].first - coo[0].first +
          min(dist(x - coo[0].first, y), dist(x - coo[N - 1].first, y));
  } else {
    for (int i = (0); i < (N); i++)
      if (coo[i].second == K) {
        K = i;
        break;
      }
    res = dist(x - coo[K].first, y) + coo[N - 1].first - coo[0].first +
          min(dist(x - coo[0].first, y), dist(x - coo[N - 1].first, y));
    res = min(res, coo[K].first - coo[0].first * 2 + coo[N - 1].first +
                       dist(x - coo[N - 1].first, y));
    res = min(res, -coo[K].first - coo[0].first + 2 * coo[N - 1].first +
                       dist(x - coo[0].first, y));
    for (int i = (1); i < (K + 1); i++) {
      res = min(res, coo[N - 1].first * 2 - coo[K].first - coo[i].first +
                         dist(x - coo[i].first, y) +
                         min(dist(x - coo[i - 1].first, y),
                             dist(x - coo[0].first, y)) +
                         coo[i - 1].first - coo[0].first);
      res = min(res, coo[K].first - 2 * coo[i].first + coo[N - 1].first +
                         di(x, y, N - 1) + min(di(x, y, 0), di(x, y, i - 1)) +
                         coo[i - 1].first - coo[0].first);
    }
    for (int i = (K); i < (N - 1); i++) {
      res = min(res, -2 * coo[0].first + coo[K].first + coo[i].first +
                         dist(x - coo[i].first, y) +
                         min(dist(x - coo[i + 1].first, y),
                             dist(x - coo[N - 1].first, y)) +
                         coo[N - 1].first - coo[i + 1].first);
      res = min(res, -coo[K].first + 2 * coo[i].first - coo[0].first +
                         di(x, y, 0) + min(di(x, y, N - 1), di(x, y, i + 1)) -
                         coo[i + 1].first + coo[N - 1].first);
    }
    if (K)
      res = min(
          res,
          coo[N - 1].first - coo[K].first + dist(x - coo[N - 1].first, y) +
              min(dist(x - coo[K - 1].first, y), dist(x - coo[0].first, y)) +
              coo[K - 1].first - coo[0].first);
    if (K != N - 1)
      res = min(res, -coo[0].first + coo[K].first + dist(x - coo[0].first, y) +
                         min(dist(x - coo[K + 1].first, y),
                             dist(x - coo[N - 1].first, y)) -
                         coo[K + 1].first + coo[N - 1].first);
  }
  printf("%.8lf\n", res);
  return 0;
}
