Hongjun Likes Physics

Find the connected induced subgraph maximizing (sum of vertex weights)/(sum of edge weights) and print its density. A fractional programming problem solved by binary searching the ratio with a maximum closure computation.

Hard8GraphBinary searchGreedyNo attempts yetTime limit2sMemory limit512 MB

Problem

Hongjun likes physics, and computing densities is his hobby.

After learning graph theory at school, Hongjun decided to define density on graphs as well. Take an undirected graph whose vertices and edges carry weights, let SumVSumV be the sum of the vertex weights and let SumESumE be the sum of the edge weights. The density of that graph is SumV/SumESumV / SumE.

For his birthday, Myungwoo gave Hongjun an undirected graph with weights on the vertices and on the edges. Hongjun wants the induced subgraph of largest density.

An induced subgraph G(V,E)G'(V', E') of a graph G(V,E)G(V, E) satisfies the following conditions.

  1. VVV' \subseteq V
  2. The edge joining uu and vv belongs to EE' if and only if uVu \in V', vVv \in V', and that edge belongs to EE.
  3. The weights of the vertices and edges of GG' are the same as in GG.
  4. GG' is connected.

An induced subgraph with no edge has SumE=0SumE = 0, so its density is undefined and it is not a candidate.

Help Hongjun and compute the density of the induced subgraph of maximum density.

Input

The first line has the number of vertices nn and the number of edges mm. (2n5002 \le n \le 500, 1mn(n1)/21 \le m \le n(n-1)/2)

The second line has nn integers separated by spaces, the weight of the ii-th vertex. Every vertex weight is between 11 and 10610^6.

Each of the next mm lines has three integers uu, vv, cc, meaning that an edge of weight cc joins vertex uu and vertex vv. Every edge weight is between 11 and 10001000, and no edge is given twice. The vertices are numbered from 11 to nn.

Output

Print the density of the induced subgraph of maximum density, rounded to six digits after the decimal point.

No input places the exact answer exactly halfway between two six-digit decimals, so the rounding direction is always determined.