#include <bits/stdc++.h>
using namespace std;
const int mn = 101000;
int X, Y, n, st;
int sa[mn], x[mn];
double ans, tmp;
double sqr(double x) { return x * x; }
double dis(int i) { return sqrt(sqr(x[i] - X) + sqr(Y)); }
double calc(int l, int r) {
  if (r < l) return 0.0;
  double res = x[r] - x[l];
  if (l <= st && st <= r)
    res += min(x[st] - x[l] + dis(r), x[r] - x[st] + dis(l));
  else
    res += min(dis(l), dis(r));
  return res;
}
bool cmp(int i, int j) { return x[i] < x[j]; }
int main() {
  scanf("%d%d", &n, &st);
  int i;
  for (i = 1; i <= n; ++i) scanf("%d", x + i);
  scanf("%d%d", &X, &Y);
  for (i = 1; i <= n; ++i) sa[i] = i;
  sort(sa + 1, sa + 1 + n, cmp);
  sort(x + 1, x + 1 + n);
  for (i = 1; i <= n; ++i)
    if (sa[i] == st) {
      st = i;
      break;
    }
  if (st == n + 1) {
    ans = x[n] - x[1] + min(dis(1), dis(n));
    printf("%.9lf\n", ans);
    return 0;
  }
  ans = 1e20;
  for (i = 1; i <= n; ++i) {
    tmp = calc(1, i - 1) + calc(i, n);
    ans = min(ans, tmp);
  }
  printf("%.9lf\n", ans);
  return 0;
}
