#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, c = getchar(), f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
int n, k, xp, yp;
struct node {
  int x, id;
  bool operator<(const node &b) const { return x < b.x; }
} p[100005];
double dist(int i) {
  return sqrt((double)yp * yp + (double)(xp - p[i].x) * (xp - p[i].x));
}
double calc1(int l, int r) {
  return (p[r].x - p[l].x +
          min(p[r].x - p[k].x + dist(l), p[k].x - p[l].x + dist(r)));
}
double calc2(int l, int r) {
  return l > r ? 0 : p[r].x - p[l].x + min(dist(l), dist(r));
}
int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) p[i] = (node){read(), i};
  xp = read(), yp = read();
  sort(p + 1, p + n + 1);
  if (k != n + 1) {
    for (int i = 1; i <= n; i++)
      if (p[i].id == k) {
        k = i;
        break;
      }
    double mn = 1e9;
    for (int i = 1; i <= n; i++)
      if (k <= i)
        mn = min(mn, calc1(1, i) + calc2(i + 1, n));
      else
        mn = min(mn, calc2(1, i) + calc1(i + 1, n));
    printf("%.12lf\n", mn);
  } else {
    printf("%.12lf\n", p[n].x - p[1].x + min(dist(n), dist(1)));
  }
}
