#include <bits/stdc++.h>
using namespace std;
struct p {
  int x, n;
} x[100001];
int n, k, ex, ey;
bool cmp(p a, p b) { return a.x < b.x; }
double dis(int k) {
  return sqrt((long long)(x[k].x - ex) * (x[k].x - ex) + (long long)ey * ey);
}
double f(int l, int r) { return min(dis(l), dis(r)) + x[r].x - x[l].x; }
double g(int k, int l, int r) {
  return min(x[k].x - x[l].x + dis(r), x[r].x - x[k].x + dis(l)) + x[r].x -
         x[l].x;
}
double cal() {
  if (k == n + 1) return f(1, n);
  int m;
  for (m = 1; m <= n; m++)
    if (x[m].n == k) break;
  double ans = g(m, 1, n);
  if (dis(m) + f(1, n) < ans) ans = dis(m) + f(1, n);
  for (int i = m; i < n; i++) {
    double tmp = g(m, 1, i) + f(i + 1, n);
    if (tmp < ans) ans = tmp;
  }
  for (int i = 2; i <= m; i++) {
    double tmp = g(m, i, n) + f(1, i - 1);
    if (tmp < ans) ans = tmp;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i].x);
    x[i].n = i;
  }
  sort(x + 1, x + n + 1, cmp);
  scanf("%d%d", &ex, &ey);
  printf("%.10lf\n", cal());
}
