#include <bits/stdc++.h>
using namespace std;
const int mm = 110000;
double x, y, xx[mm];
int n, m, xxm;
double C(int z) { return hypot(x - xx[z], y); }
double A(int l, int r) {
  double z = xx[r] - xx[l] + min(C(l), C(r));
  return z;
}
double B(int l, int r) {
  double z;
  z = xx[r] - xx[l] + min(C(l) + abs(xxm - xx[r]), C(r) + abs(xxm - xx[l]));
  return z;
}
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) cin >> xx[i];
    cin >> x >> y;
    xxm = xx[m - 1];
    sort(xx, xx + n);
    double ans;
    if (m == n + 1)
      ans = A(0, n - 1);
    else {
      ans = B(0, n - 1);
      for (int i = 1; i < n; i++) {
        double z;
        z = min(A(0, i - 1) + B(i, n - 1), A(i, n - 1) + B(0, i - 1));
        ans = ans < z ? ans : z;
      }
    }
    cout << fixed << setprecision(20) << ans << "\n";
  }
}
