#include <bits/stdc++.h>
using namespace std;
vector<double> x;
pair<double, double> z;
double kx;
double doz(int i) { return hypot(z.first - x[i], z.second); }
double po_robu(int l, int r) { return x[r] - x[l] + min(doz(l), doz(r)); }
double po_sredi(int l, int r) {
  return x[r] - x[l] + min(doz(l) + abs(kx - x[r]), doz(r) + abs(kx - x[l]));
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    x.push_back(0);
    cin >> x[i];
  }
  if (k != n + 1) kx = x[k - 1];
  sort(x.begin(), x.end());
  cin >> z.first >> z.second;
  if (n == 1) {
    cout << fixed << setprecision(12) << doz(0) << "\n";
    return 0;
  }
  if (k == n + 1) {
    cout << fixed << setprecision(12) << po_robu(0, n - 1) << "\n";
    return 0;
  }
  double rez = po_sredi(0, n - 1);
  for (int i = 0; i < n; i++) {
    double rez2 = min(po_robu(0, i - 1) + po_sredi(i, n - 1),
                      po_sredi(0, i - 1) + po_robu(i, n - 1));
    if (rez2 < rez) rez = rez2;
  }
  cout << fixed << setprecision(12) << rez << "\n";
  return 0;
}
