#include <bits/stdc++.h>
using namespace std;
enum { MAXN = 100010 };
int x[MAXN];
double dist(int xi, int xp, int yp) {
  return sqrt(double(xp - xi) * (xp - xi) + (double)yp * yp);
}
const double INF = 1e20;
int main() {
  int n, m, xm;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  xm = x[m];
  sort(x + 1, x + 1 + n);
  if (m != n + 1) m = lower_bound(x + 1, x + 1 + n, xm) - x;
  int xp, yp;
  scanf("%d%d", &xp, &yp);
  double ans = INF;
  if (m == 1) {
    for (int i = 1; i <= n; i++) {
      ans = min(ans,
                x[i] - x[1] + dist(x[i], xp, yp) +
                    (i == n ? 0
                            : min(dist(x[i + 1], xp, yp), dist(x[n], xp, yp)) +
                                  x[n] - x[i + 1]));
    }
  } else if (m == n) {
    for (int i = 1; i <= n; i++) {
      ans = min(ans, (i == 1 ? 0
                             : min(dist(x[1], xp, yp), dist(x[i - 1], xp, yp)) +
                                   x[i - 1] - x[1]) +
                         x[n] - x[i] + dist(x[i], xp, yp));
    }
  } else if (m == n + 1) {
    ans = min(ans, min(dist(x[1], xp, yp), dist(x[n], xp, yp)) + x[n] - x[1]);
  } else {
    ans =
        min(ans, dist(x[m], xp, yp) +
                     min(dist(x[1], xp, yp), dist(x[n], xp, yp)) + x[n] - x[1]);
    ans = min(ans, dist(x[1], xp, yp) + x[m] - x[1] +
                       min(dist(x[m + 1], xp, yp), dist(x[n], xp, yp)) + x[n] -
                       x[m + 1]);
    ans = min(ans, min(dist(x[1], xp, yp), dist(x[m - 1], xp, yp)) + x[m - 1] -
                       x[1] + x[n] - x[m] + dist(x[n], xp, yp));
    for (int i = m + 1; i <= n; i++) {
      ans = min(ans,
                x[i] - x[1] +
                    min(dist(x[i], xp, yp) + x[m] - x[1],
                        dist(x[1], xp, yp) + x[i] - x[m]) +
                    (i == n ? 0
                            : min(dist(x[i + 1], xp, yp), dist(x[n], xp, yp)) +
                                  x[n] - x[i + 1]));
    }
    for (int i = 1; i < m; i++) {
      ans = min(ans, (i == 1 ? 0
                             : min(dist(x[1], xp, yp), dist(x[i - 1], xp, yp)) +
                                   x[i - 1] - x[1]) +
                         x[n] - x[i] +
                         min(dist(x[i], xp, yp) + x[n] - x[m],
                             dist(x[n], xp, yp) + x[m] - x[i]));
    }
  }
  printf("%.15f\n", ans);
  return 0;
}
