#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 1e9;
const long long INF64 = 1e18;
const long double EPS = 1e-9;
int n, k;
const int N = 100005;
long double first[N];
long double second[N];
pair<long double, long double> f;
void gen() {
  set<int> s;
  n = 4;
  for (int i = 0; i < int(n); ++i) {
    first[i] = rand() % 20;
    if (s.count(first[i]))
      i--;
    else
      s.insert(first[i]);
  }
  k = rand() % n;
  f = make_pair(rand() % 20, rand() % 20);
  sort(first, first + n);
}
bool read() {
  if (!(cin >> n >> k)) return false;
  k--;
  for (int i = 0; i < int(n); ++i) {
    cin >> first[i];
  }
  cin >> f.first >> f.second;
  int st = first[k];
  sort(first, first + n);
  if (k == n) {
    long double ans1 = sqrt(((first[0] - f.first) * (first[0] - f.first)) +
                            ((f.second) * (f.second))) +
                       first[n - 1] - first[0];
    long double ans2 =
        sqrt(((first[n - 1] - f.first) * (first[n - 1] - f.first)) +
             ((f.second) * (f.second))) +
        first[n - 1] - first[0];
    cout << fixed << setprecision(10) << min(ans1, ans2) << endl;
    exit(0);
  }
  for (int i = 0; i < int(n); ++i)
    if (first[i] == st) k = i;
  return true;
}
long double dist(int v) {
  if (v < 0 || v >= n) return 0;
  return sqrt(((f.first - first[v]) * (f.first - first[v])) +
              ((f.second) * (f.second)));
}
long double naive() {
  first[n] = f.first, second[n] = f.second;
  vector<int> v;
  for (int i = 0; i < int(n + 1); ++i) v.push_back(i);
  long double ans = INF;
  do {
    if (v[0] != k) continue;
    long double cur = 0;
    for (int i = 0; i < int(n); ++i) {
      cur += sqrt(
          ((first[v[i]] - first[v[i + 1]]) * (first[v[i]] - first[v[i + 1]])) +
          ((second[v[i]] - second[v[i + 1]]) *
           (second[v[i]] - second[v[i + 1]])));
    }
    ans = min(ans, cur);
  } while (next_permutation(v.begin(), v.end()));
  return ans;
}
void solve() {
  long double ans = INF;
  long double cur = 0;
  for (int i = 0; i < int(n); ++i) {
    cur = first[k] - first[0] + first[i] - first[0];
    cur += dist(i);
    int r = max(i + 1, k + 1);
    if (r < n) cur += min(dist(r), dist(n - 1)) + first[n - 1] - first[r];
    ans = min(ans, cur);
    cur = first[n - 1] - first[k] + first[n - 1] - first[i];
    cur += dist(i);
    int l = min(i - 1, k - 1);
    if (l >= 0) cur += min(dist(0), dist(l)) + first[l] - first[0];
    ans = min(ans, cur);
    cur = abs(first[k] - first[i]) + first[i] - first[0];
    cur += dist(0);
    r = max(i + 1, k + 1);
    if (r < n) cur += min(dist(r), dist(n - 1)) + first[n - 1] - first[r];
    ans = min(ans, cur);
    cur = abs(first[i] - first[k]) + first[n - 1] - first[i];
    cur += dist(n - 1);
    l = min(i - 1, k - 1);
    if (l >= 0) cur += min(dist(0), dist(l)) + first[l] - first[0];
    ans = min(ans, cur);
  }
  cout << fixed << setprecision(10) << ans << endl;
}
int main() {
  while (read()) solve();
  return 0;
}
