#include <bits/stdc++.h>
using namespace std;
long long fpm(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class edge>
struct Graph {
  vector<vector<edge> > adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  void adde(int s, edge e) { adj[s].push_back(e); }
  typename vector<edge>::iterator operator[](int t) { return adj[t].begin(); }
};
const int maxn = 110000;
int x[maxn], y, n, k;
double dist(int L, int R) {
  if (L > R) return 0;
  return min(hypot(y, x[1 + n] - x[L]), hypot(y, x[1 + n] - x[R])) + x[R] -
         x[L];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n + 1; ++i) cin >> x[i];
  cin >> y;
  cout << setprecision(15);
  int bak = x[k], xw = x[n + 1];
  sort(x + 1, x + 1 + n);
  if (k > n) return cout << dist(1, n) << endl, 0;
  k = lower_bound(x + 1, x + 1 + n, bak) - x;
  double ans = hypot(x[k] - xw, y) + dist(1, n);
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, fabs(x[k] - x[n]) + fabs(x[n] - x[i]) +
                       dist(1, min(i, k) - 1) + hypot(x[i] - xw, y));
    ans = min(ans, fabs(x[k] - x[1]) + fabs(x[1] - x[i]) +
                       dist(max(i, k) + 1, n) + hypot(x[i] - xw, y));
    ans = min(ans, fabs(x[k] - x[i]) + fabs(x[i] - x[n]) +
                       dist(1, min(i, k) - 1) + hypot(x[n] - xw, y));
    ans = min(ans, fabs(x[k] - x[i]) + fabs(x[i] - x[1]) +
                       dist(max(i, k) + 1, n) + hypot(x[1] - xw, y));
  }
  cout << ans << endl;
  return 0;
}
