Problem: Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.

King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordinate system on it. Every city is a point on this plane. There are n cities in the kingdom at points with coordinates (x1, 0), (x2, 0), ..., (xn, 0), and there is one city at point (xn + 1, yn + 1). 

King starts his journey in the city number k. Your task is to find such route for the king, which visits all cities (in any order) and has minimum possible length. It is allowed to visit a city twice. The king can end his journey in any city. Between any pair of cities there is a direct road with length equal to the distance between the corresponding points. No two cities may be located at the same point.

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n + 1) — amount of cities and index of the starting city. The second line contains n + 1 numbers xi. The third line contains yn + 1. All coordinates are integers and do not exceed 106 by absolute value. No two cities coincide.

Output

Output the minimum possible length of the journey. Your answer must have relative or absolute error less than 10 - 6.

Examples

Input

3 1
0 1 2 1
1


Output

3.41421356237309490000

Input

3 1
1 0 2 1
1


Output

3.82842712474619030000

Input

4 5
0 5 -1 -5 2
3


Output

14.24264068711928400000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
int N, K;
int _x[200000];
double x[200000], xp, yp, ans;
template <class T>
inline T sqr(T x) {
  return x * x;
}
struct point {
  double x, y;
  point() {}
  point(double _x, double _y) : x(_x), y(_y) {}
};
inline double dis(const point &a, const point &b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
int main() {
  scanf("%d%d", &N, &K);
  int flag = (K == N + 1);
  for (int i = (1); i <= (N); ++i) scanf("%d", &_x[i]);
  int target = _x[K];
  sort(_x + 1, _x + N + 1);
  N = unique(_x + 1, _x + N + 1) - _x - 1;
  for (int i = (1); i <= (N); ++i)
    if (_x[i] == target) K = i;
  for (int i = (1); i <= (N); ++i) x[i] = _x[i];
  scanf("%lf%lf", &xp, &yp);
  if (N == 1) {
    ans = dis(point(xp, yp), point(x[1], 0));
  } else if (flag) {
    ans = x[N] - x[1] +
          min(sqrt(sqr(yp) + sqr(xp - x[1])), sqrt(sqr(yp) + sqr(xp - x[N])));
  } else {
    ans = 1e30;
    point a = point(x[K], 0);
    point b = point(x[1], 0);
    point c = point(x[N], 0);
    point d = point(xp, yp);
    ans = min(ans, dis(a, b) + dis(b, c) + dis(c, d));
    ans = min(ans, dis(a, b) + dis(b, d) + dis(d, c) +
                       (K != N) * dis(c, point(x[K + 1], 0)));
    ans = min(ans, dis(a, c) + dis(c, b) + dis(b, d));
    ans = min(ans, dis(a, c) + dis(c, d) + dis(d, b) +
                       (K != 1) * dis(point(x[K - 1], 0), b));
    if (K != 1)
      ans = min(ans, dis(a, c) + dis(c, d) + dis(d, point(x[K - 1], 0)) +
                         x[K - 1] - x[1]);
    if (K != N)
      ans = min(ans, dis(a, b) + dis(b, d) + dis(d, point(x[K + 1], 0)) + x[N] -
                         x[K + 1]);
    ans = min(ans, dis(a, d) + dis(d, b) + dis(b, c));
    ans = min(ans, dis(a, d) + dis(d, c) + dis(c, b));
    if (K == N) {
      ans = min(ans, dis(a, d) + dis(d, point(x[K - 1], 0)) +
                         dis(point(x[K - 1], 0), b));
      for (int i = (1); i <= (N); ++i) {
        ans = min(ans, x[N] - x[i] + dis(point(x[i], 0), d) +
                           dis(d, point(x[i - 1], 0)) + x[i - 1] - x[1]);
      }
    }
    if (K == 1) {
      ans = min(ans, dis(a, d) + dis(d, point(x[K + 1], 0)) +
                         dis(point(x[K + 1], 0), c));
      for (int i = (1); i <= (N); ++i) {
        ans = min(ans, x[i] - x[1] + dis(point(x[i], 0), d) +
                           dis(d, point(x[i + 1], 0)) + x[N] - x[i + 1]);
      }
    }
    if (x[K] >= xp) {
      for (int t = (1); t <= (N); ++t) {
        double ret = 0;
        ret += 2 * dis(point(x[K], 0), c);
        ret += abs(x[K] - x[t]);
        ret += dis(point(x[t], 0), d);
        if (t - 1 > 0) ret += dis(d, point(x[t - 1], 0));
        if (t - 2 > 0) ret += abs(x[t - 1] - x[1]);
        ans = min(ans, ret);
        ret = 0;
        ret += 2 * abs(x[K] - x[t]);
        ret += abs(x[N] - x[K]);
        ret += dis(c, d);
        if (t - 1 > 0) ret += dis(d, point(x[t - 1], 0));
        if (t - 2 > 0) ret += abs(x[t - 1] - x[1]);
        ans = min(ans, ret);
      }
    } else {
      for (int t = (1); t <= (N); ++t) {
        double ret = 0;
        ret += 2 * dis(point(x[K], 0), b);
        ret += abs(x[t] - x[K]);
        ret += dis(point(x[t], 0), d);
        if (t + 1 <= N) ret += dis(d, point(x[t + 1], 0));
        if (t + 2 <= N) ret += abs(x[N] - x[t + 1]);
        ans = min(ans, ret);
        ret = 0;
        ret += 2 * abs(x[t] - x[K]);
        ret += abs(x[K] - x[1]);
        ret += dis(b, d);
        if (t + 1 <= N) ret += dis(d, point(x[t + 1], 0));
        if (t + 2 <= N) ret += abs(x[N] - x[t + 1]);
        ans = min(ans, ret);
      }
    }
    for (int t = (K + 1); t <= (N); ++t) {
      double ret = 0;
      ret += 2 * (x[t] - x[K]);
      ret += x[K] - x[1];
      ret += dis(b, d);
      ret += dis(d, c);
      ret += x[N] - x[t + 1];
      ans = min(ans, ret);
      ret = 0;
      ret += 2 * (x[t] - x[K]);
      ret += x[K] - x[1];
      ret += dis(b, d);
      ret += dis(d, point(x[t + 1], 0));
      ret += x[N] - x[t + 1];
      ans = min(ans, ret);
    }
    for (int t = (1); t <= (K - 1); ++t) {
      double ret = 0;
      ret += 2 * (x[K] - x[t]);
      ret += x[N] - x[K];
      ret += dis(b, d);
      ret += dis(d, c);
      ret += x[t - 1] - x[1];
      ans = min(ans, ret);
      ret = 0;
      ret += 2 * (x[K] - x[t]);
      ret += x[N] - x[K];
      ret += dis(point(x[1], 0), d);
      ret += dis(d, c);
      ret += x[t - 1] - x[1];
      ans = min(ans, ret);
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}