Landmarks

We have an old building with n + 2 columns in a row. These columns support the ceiling. These columns are located in points with coordinates 0 = x 0 < x 1 < … < x n < x n + 1. The leftmost and the rightmost columns are special, we will call them bearing, the other columns are ordinary.

For each column we know its durability d i. Let’s consider an ordinary column with coordinate x. Let’s assume that the coordinate of the closest to it column to the left (bearing or ordinary) is a and the coordinate of the closest to it column to the right (also, bearing or ordinary) is b. In this task let’s assume that this column supports the segment of the ceiling from point  to point  (here both fractions are considered as real division). If the length of the segment of the ceiling supported by the column exceeds d i, then the column cannot support it and it crashes after a while, and after that the load is being redistributeed between the neighbouring columns according to the same principle.

Thus, ordinary columns will be crashing for some time until the process stops at some state. One can prove that the set of the remaining columns doesn’t depend on the order in which columns crash. If there are only two bearing columns left in the end, then we assume that the whole construction crashes under the weight of the roof. But if at least one ordinary column stays in addition to the bearing ones, then the building doesn’t crash.

To make the building stronger, we can add one extra ordinary column of arbitrary durability d‘ at any (not necessarily integer) point 0 < x‘ < x n + 1. If point x‘ is already occupied by an ordinary column, it is replaced by a new one.

Your task is to find out: what minimal durability can the added column have so that the building doesn’t crash?

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of ordinary columns.

The second line contains n + 2 integers x 0, x 1, …, x n, x n + 1 ( x 0 = 0, x i < x i + 1 for 0 ≤ i ≤ nx n + 1 ≤ 109) — the coordinates of the columns.

The third line contains n integers d 1, d 2, …, d n (1 ≤ d i ≤ 109).

Output

Print a single number — the minimum possible durability of the column that you need to add in order to make the building stay. If you do not have to add the column, please print 0. Your answer will be checked with the relative or absolute error 10 - 4.

Examples

input

2
0 20 40 100
15 40

output

10

input

3
0 4 10 28 30
9 13 5

output

0

Solution:

#include <bits/stdc++.h>

using namespace std;

const long long inf = (long long)1e10;
const long long N = 400010;

long long fenw[N];
long long esz;

void modify(long long x, long long v) {
while (x <= esz) {
    if (v < fenw[x]) fenw[x] = v;
    x = (x | (x - 1)) + 1;
  }
}

long long find_min(long long x) {
  long long v = inf;
  while (x > 0) {
if (fenw[x] < v) v = fenw[x];
    x &= x - 1;
  }
  return v;
}

long long x[N], d[N];
long long st[N];
long long l[N], r[N];
long long pos[N];

int main() {
  int n;
  scanf("%d", &n);
  for (long long i = 0; i <= n + 1; i++) {
    int foo;
    scanf("%d", &foo);
    x[i] = foo;
  }
  for (long long i = 1; i <= n; i++) {
    int foo;
    scanf("%d", &foo);
    d[i] = 2LL * foo;
  }
  d[0] = d[n + 1] = x[n + 1] - x[0];
  r[0] = d[0];
  long long e = 1;
  st[0] = 0;
  for (long long i = 1; i <= n + 1; i++) {
    while (e >= 2 && d[st[e - 1]] < x[i] - x[st[e - 2]]) {
      e--;
    }
    r[i] = d[i] - (x[i] - x[st[e - 1]]);
    st[e++] = i;
  }
  if (e > 2) {
printf("0.0\n");
return 0;
}
l[n + 1] = d[n + 1];
e = 1;
st[0] = n + 1;
for (long long i = n; i >= 0; i--) {
while (e >= 2 && d[st[e - 1]] < x[st[e - 2]] - x[i]) {
      e--;
    }
    l[i] = d[i] - (x[st[e - 1]] - x[i]);
    st[e++] = i;
  }
  r[n + 1] = -inf;
  l[0] = -inf;
  vector < pair <long long, long long> > ev;
for (long long i = 0; i <= n + 1; i++) {
    if (l[i] <= 0) {
      continue;
    }
    ev.push_back(make_pair(x[i] - l[i], i));
  }
  sort(ev.begin(), ev.end());
  esz = ev.size();
  for (long long q = 0; q < esz; q++) {
    pos[ev[q].second] = q + 1;
  }
  for (long long q = 1; q <= esz; q++) {
    fenw[q] = inf;
  }
  long long ans = inf;
  for (long long i = n + 1; i >= 0; i--) {
if (r[i] > 0) {
long long to = x[i] + r[i];
long long to_pos = lower_bound(ev.begin(), ev.end(), make_pair(to + 1, -1LL)) - ev.begin();
long long u = find_min(to_pos);
if (u != inf) {
if (u - x[i] < ans) {
          ans = u - x[i];
        }
      }
    }
    if (l[i] > 0) {
modify(pos[i], x[i]);
}
}
cout << (ans / 2) << "." << (ans % 2 * 5) << endl;
  return 0;
}