Within Arm's Reach

Given segment lengths of a planar robotic arm and a target point, find where the tip lands when bent as close to the target as possible.

Medium5GeometryMathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Joao wants to join his university's robot soccer team. He knows little about robotics or mathematics yet, so he decided to build a two dimensional robotic arm first and learn from it.

The arm is made of NN segments. One end of the first segment is pinned to the origin, and one end of segment ii is joined to the far end of segment i1i-1. Any angle between two neighboring segments is allowed, including angles that make the arm look like it overlaps itself when seen from above. Bending the arm never changes a segment length.

The free end of segment NN is the tip of the arm. Given the segment lengths and a target point, find where the tip sits when the arm is bent so that the tip is as close to the target as possible.

Several configurations can tie for the smallest distance, but they all put the tip on the same point. There is one exception. If the target is the origin and the tip cannot reach the origin, the closest points form a full circle, and then the answer is the configuration that puts the tip on the positive xx axis, so the answer has y=0y = 0 and x>0x > 0.

Input

The first line contains NN, the number of segments. Each of the next NN lines contains LiL_i, the length of the ii-th segment counted from the origin toward the tip. The last line contains the coordinates xx and yy of the target, separated by a space.

Output

Print the coordinates xtx_t and yty_t of the tip on one line, rounded to three decimal places and separated by a space. Print a coordinate that rounds to zero as 0.000, not as -0.000.

Limits

  • 1N201 \le N \le 20: the number of segments in the arm
  • 1Li10001 \le L_i \le 1000: the length of the ii-th segment
  • 20000x,y20000-20000 \le x, y \le 20000: the coordinates of the target

Every input value is an integer.

Figure

The figure shows the case with segment lengths 5, 3, 4 and target (5,3)(5, 3). The circled cross marks the target, and the square marks the end pinned to the origin.