#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
long double x[N], y;
int k, n;
inline long double sqr(long double x) { return x * x; }
inline long double dis(int p) { return sqrt(sqr(x[n + 1] - x[p]) + sqr(y)); }
inline long double dis(int l, int r) {
  if (l > r) return 0;
  return min(dis(l), dis(r)) + x[r] - x[l];
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n + 1; ++i) cin >> x[i];
  cin >> y;
  long double p = x[k];
  sort(x + 1, x + 1 + n);
  if (k == n + 1) {
    cout.setf(ios::fixed);
    cout << setprecision(18) << dis(1, n) << endl;
    return 0;
  }
  k = lower_bound(x + 1, x + 1 + n, p) - x;
  long double res = 1e300;
  for (int i = k; i <= n; ++i) {
    long double a = x[k] - x[1] + x[i] - x[1] + dis(i) + dis(i + 1, n),
                b = x[i] - x[1] + x[i] - x[k] + dis(1) + dis(i + 1, n);
    res = min(res, min(a, b));
  }
  for (int i = 1; i <= k; ++i) {
    long double a = x[n] - x[i] + x[k] - x[i] + dis(n) + dis(1, i - 1),
                b = x[n] - x[i] + x[n] - x[k] + dis(i) + dis(1, i - 1);
    res = min(res, min(a, b));
  }
  cout.setf(ios::fixed);
  cout << setprecision(18) << res << endl;
  return 0;
}
