Under construction

Still being built. Things may change

Complaints Pile Up

Time limit5sMemory limit512 MB

Summary
Find the largest integer volume V so that each speaker's Manhattan-distance sound range, with radius V times its size, never overlaps another speaker's range.
Level

Hard8 of 10

Topics
Binary search, Geometry, Divide and conquer
Solved
No attempts yet

Problem

DJ Wookje wanted to show people how good his DJing was. At 3 a.m. he drove a supercar around the apartment complex and started spinning at full volume.

One speaker was not enough to reach artistic heights. So DJ Wookje decided to do wide-area DJing (wide-area dealing).

  1. The apartment complex is a 2D grid, and the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is ∣x1−x2∣+∣y1−y2∣|x_1 - x_2| + |y_1 - y_2|.
  2. DJ Wookje placed NN speakers, with the ii-th speaker at (xi,yi)(x_i, y_i).
  3. Each speaker has a size. If the ii-th speaker has size SiS_i and the volume is VV, its music can be heard at every point within distance V×SiV \times S_i of that speaker.
  4. The volume can only be set to whole numbers, and every speaker has the same volume.
  5. 『 Art is volume. 』

DJ Wookje keeps raising the volume and is getting closer to artistic heights. However, some people who do not appreciate art file complaints when they hear music from two or more speakers at once. So DJ Wookje decided to raise the volume as far as possible without any complaints. If the boundary of a sound range or a boundary point overlaps with another, the music does not count as overlapping.

Feel the art (volume) of DJ Wookje! How large can the art (volume) of DJ Wookje get?

Input

The first line contains the number of speakers NN.

The second line contains the sizes S1,S2,…,SNS_1, S_2, \ldots, S_N in order.

From the third line onward, the (i+2)(i+2)-th line contains the coordinates xi,yix_i, y_i of speaker ii. No two coordinates are the same.

All input values are integers greater than or equal to 1.

Output

Print the maximum size of the art (volume) that DJ Wookje can reach.

Constraints

  • 2≤N≤1000002 \le N \le 100000
  • 1≤Si≤10001 \le S_i \le 1000
  • 1≤xi,yi≤10000001 \le x_i, y_i \le 1000000

Examples2

  1. Example 1

    Input
    4
    2 1 1 3
    2 2
    1 7
    6 6
    5 13
    
    Expected output
    2
    
  2. Example 2

    Input
    2
    1 1
    1 1
    1000000 1000000
    
    Expected output
    999999