#include <bits/stdc++.h>
using namespace std;
int x, y, X[120000], s, xx, n, i;
double ans = 1e11;
double dis(double X) { return sqrt((X - x) * (X - x) + (double)y * y); }
double tl(int l, int r) {
  if (r < s || l > s) return 1e10;
  return min(X[r] - X[s] + dis(X[l]), X[s] - X[l] + dis(X[r])) + X[r] - X[l];
}
double tr(int l, int r) {
  if (l > r) return 0;
  return min(dis(X[l]), dis(X[r])) + X[r] - X[l];
}
int main() {
  scanf("%d%d", &n, &s);
  for (i = 1; i <= n; ++i) scanf("%d", &X[i]);
  scanf("%d%d", &x, &y);
  xx = X[s];
  sort(X + 1, X + n + 1);
  if (s == n + 1) {
    printf("%.18lf\n", min(dis(X[1]), dis(X[n])) + X[n] - X[1]);
    return 0;
  }
  for (s = 1; s <= n; ++s)
    if (X[s] == xx) break;
  for (i = 1; i <= n; ++i)
    ans = min(ans, min(tl(1, i) + tr(i + 1, n), tr(1, i - 1) + tl(i, n)));
  printf("%.18lf\n", ans);
}
