#include <bits/stdc++.h>
using namespace std;
int x[110000];
int x1, boyva235;
int n, k;
long double dest(int x, int y, int x1, int boyva235) {
  long double dx = x - x1;
  long double dy = y - boyva235;
  return sqrtl(dx * dx + dy * dy);
}
long double dest(int p) { return dest(x[p], 0, x1, boyva235); }
int main() {
  scanf("%d %d", &n, &k);
  --k;
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  scanf("%d %d", &x1, &boyva235);
  if (k == n) {
    sort(x, x + n);
    long double ans = dest(0) + x[n - 1] - x[0];
    ans = min(ans, dest(n - 1) + x[n - 1] - x[0]);
    cout.precision(15);
    cout << fixed << ans << endl;
    return 0;
  }
  int sx = x[k];
  sort(x, x + n);
  for (int i = 0; i < n; i++)
    if (x[i] == sx) {
      k = i;
      break;
    }
  long double ans = 1e+100;
  for (int i = 0; i <= k; i++) {
    long double tmp1 = x[k] - x[i] + x[n - 1] - x[i] + dest(n - 1);
    tmp1 = min(tmp1, x[n - 1] - x[k] + x[n - 1] - x[i] + dest(i));
    if (i != 0) {
      tmp1 += x[i - 1] - x[0];
      tmp1 += min(dest(0), dest(i - 1));
    }
    ans = min(ans, tmp1);
  }
  for (int i = k; i < n; i++) {
    long double tmp1 = x[i] - x[k] + x[i] - x[0] + dest(0);
    tmp1 = min(tmp1, x[k] - x[0] + x[i] - x[0] + dest(i));
    if (i != n - 1) {
      tmp1 += x[n - 1] - x[i + 1];
      tmp1 += min(dest(i + 1), dest(n - 1));
    }
    ans = min(ans, tmp1);
  }
  cout.precision(15);
  cout << fixed << ans << endl;
  return 0;
}
