#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int idx[MAXN], ep[2], kidx;
int n, k;
double ans;
void init() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", &idx[i]);
  kidx = idx[--k];
  scanf("%d%d", ep, ep + 1);
}
double dist(double x) {
  return sqrt((double)(ep[0] - x) * (ep[0] - x) + (double)ep[1] * ep[1]);
}
double up(int l, int r) {
  return fabs((double)idx[r] - idx[l]) + fabs((double)idx[k] - idx[l]);
}
double down(int l, int r) {
  return fabs((double)idx[r] - idx[l]) + min(dist(idx[l]), dist(idx[r]));
}
void solve() {
  sort(idx, idx + n);
  if (k == n) {
    ans = min(dist(idx[0]), dist(idx[n - 1])) + idx[n - 1] - idx[0];
    return;
  }
  for (int i = 0; i < n; ++i)
    if (kidx == idx[i]) {
      k = i;
      break;
    }
  if (n == 1) {
    ans = dist(idx[k]);
    return;
  }
  ans = min(up(0, n - 1) + dist(idx[n - 1]), up(n - 1, 0) + dist(idx[0]));
  for (int i = 0; i < n; ++i) {
    if (i < n - 1) {
      ans = min(ans, up(0, i) + dist(idx[i]) + down(i + 1, n - 1));
      ans = min(ans, up(i, 0) + dist(idx[0]) + down(i + 1, n - 1));
    }
    if (0 < i) {
      ans = min(ans, up(i, n - 1) + dist(idx[n - 1]) + down(0, i - 1));
      ans = min(ans, up(n - 1, i) + dist(idx[i]) + down(0, i - 1));
    }
  }
}
int main() {
  init();
  solve();
  printf("%.9lf\n", ans);
  return 0;
}
