Square in Circles

Given overlapping circles centered on the x-axis, find the side length of the largest axis-aligned square that fits inside their union.

Hard8GeometryBinary searchNo attempts yetTime limit8sMemory limit512 MB

Problem

Circles Island is completely flat. Its shape is the union of several circles together with their interiors, and every circle has its center on the x-axis.

The king of Circles Island wants to build a large square plaza for the fiftieth anniversary of his accession, and he wants the plaza as large as possible. The whole plaza must lie on the island, and any part of the island may be used. The plaza must be a square, and one of its sides must be parallel to the x-axis.

You are given the center and the radius of every circle that forms the island. Report the side length of the largest square that can be built.

The circles are given in increasing order of the x-coordinate of their centers. For every ii (1iN1)(1 \le i \le N-1), circle ii and circle i+1i+1 overlap. No circle is completely covered by the other circles.

Figure 1. The island of the first example and one of its largest squares

Input

The input has several datasets, at most 30 of them. Each dataset is in this format.

N
X1 R1
:
XN RN

The first line of a dataset has one integer NN (1N50000)(1 \le N \le 50000), the number of circles that form the island. Line ii of the next NN lines has two integers XiX_i (100000Xi100000)(-100000 \le X_i \le 100000) and RiR_i (1Ri100000)(1 \le R_i \le 100000). Circle ii has its center at (Xi,0)(X_i, 0) and its radius is RiR_i.

You may assume the following.

  • Xi<Xi+1X_i < X_{i+1} for every ii (1iN1)(1 \le i \le N-1).
  • Circle ii and circle i+1i+1 share at least one point for every ii (1iN1)(1 \le i \le N-1), that is, Xi+1XiRi+Ri+1X_{i+1} - X_i \le R_i + R_{i+1}.
  • Every circle has at least one point that is neither inside nor on the boundary of any other circle.

The end of the input is a line that holds a single zero.

Output

For each dataset, print the side length of the largest square on its own line, rounded to six digits after the decimal point.