#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
struct POINT {
  int x, y;
} a[MAXN];
int n, p;
inline bool cmp(const POINT &a, const POINT &b) { return a.x < b.x; }
double ans = 1e9;
inline double dis(double x1, double y1, double x2, double y2) {
  return sqrt((double)(x1 - x2) * (x1 - x2) + (double)(y1 - y2) * (y1 - y2));
}
inline double D(int l, int r) {
  if (l > r) return 0;
  return min(dis(a[l].x, 0, a[n + 1].x, a[n + 1].y),
             dis(a[r].x, 0, a[n + 1].x, a[n + 1].y)) +
         a[r].x - a[l].x;
}
void work() {
  double ll = a[1].x, rr = a[n].x;
  double t = dis(a[p].x, a[p].y, a[n + 1].x, a[n + 1].y) + D(1, n);
  if (t < ans) ans = t;
  t = rr - a[p].x + dis(rr, 0, a[n + 1].x, a[n + 1].y) + D(1, p - 1);
  if (t < ans) ans = t;
  t = a[p].x - ll + dis(ll, 0, a[n + 1].x, a[n + 1].y) + D(p + 1, n);
  if (t < ans) ans = t;
  for (int i = 1; i <= p; i++) {
    double tmp = rr - a[p].x + rr - a[i].x +
                 dis(a[i].x, 0, a[n + 1].x, a[n + 1].y) + D(1, i - 1);
    if (tmp < ans) ans = tmp;
    tmp = a[p].x - a[i].x + rr - a[i].x + dis(rr, 0, a[n + 1].x, a[n + 1].y) +
          D(1, i - 1);
    if (tmp < ans) ans = tmp;
  }
  for (int i = p; i <= n; i++) {
    double tmp = a[p].x - ll + a[i].x - ll +
                 dis(a[i].x, 0, a[n + 1].x, a[n + 1].y) + D(i + 1, n);
    if (tmp < ans) ans = tmp;
    tmp = a[i].x - a[p].x + a[i].x - ll + dis(ll, 0, a[n + 1].x, a[n + 1].y) +
          D(i + 1, n);
    if (tmp < ans) ans = tmp;
  }
}
int main() {
  scanf("%d%d", &n, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    a[i].y = 0;
  }
  scanf("%d", &a[n + 1].x);
  scanf("%d", &a[n + 1].y);
  int tx = a[p].x, ty = a[p].y;
  sort(a + 1, a + n + 1, cmp);
  if (p == n + 1) {
    double ll = a[1].x, rr = a[n].x;
    ans = D(1, n);
    printf("%.9lf\n", ans);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (a[i].x == tx && a[i].y == ty) {
      p = i;
      break;
    }
  work();
  printf("%.9lf\n", ans);
  return 0;
}
