First Pair to Meet

Given people at vertices of a weighted undirected graph, find the minimum over all pairs of half their shortest-path distance; roads are traversed at 10 km/h and the time prints in minutes.

Hard8GraphShortest pathMathSortingNo attempts yetTime limit2sMemory limit512 MB

Problem

ACM Telecom is running an event to promote its new app, "Meeting Route". The first two people who meet through the app get a prize.

Right before the event starts, everyone knows where everyone else is from the app. Once two people decide to meet, they start at the same moment and move toward each other along the shortest route the app gives them. Everyone moves at 10 km/h. If the shortest route between two people is dd km long, each of them covers d/2d/2 km and then they meet.

To prepare the award ceremony, ACM Telecom needs the smallest time the event can take. Given the positions of the people when the event starts and the map of the area, compute that time.

Input

The first line contains the number of participants NN, the number of vertices KK on the map, and the number of roads LL joining the vertices. (2N1000002 \le N \le 100000, 1K1000001 \le K \le 100000, 1L1000001 \le L \le 100000)

Each of the next NN lines contains one number SiS_i, the position of a person. (1SiK1 \le S_i \le K) It means person ii stands at vertex SiS_i. Several people may stand at the same vertex.

Each of the next LL lines describes one road as BiB_i, CiC_i, DiD_i. (1BiCiK1 \le B_i \ne C_i \le K, 1Di50001 \le D_i \le 5000) It means there is a road of length DiD_i km between vertex BiB_i and vertex CiC_i. Roads can be travelled in both directions, and the same two vertices may be joined by more than one road.

Output

Print one integer, the shortest time in minutes it takes for some two people to meet. At least one pair of people can reach each other. Two people who start at the same vertex meet at once, so the answer can be 0.