Website Speed Analysis
Over the past year, the number of pages on the website of school No. 1024 has grown significantly. To optimize the site's structure, an analysis of the links between the pages is needed.
Each page has a known loading time, and information about the existing links between pages is available. If there is a link between page i and page j, then there is also a link from page j to page i. Your task is to determine the minimum time required to navigate from page A to page B, taking into account the loading times of page A, page B, and any intermediate pages.
Input Data
The first line contains two natural numbers: N (1 ≤ N ≤ 1000), representing the number of pages on the site, and K (1 ≤ K ≤ 1000000), representing the number of links.
The second line contains N numbers, each representing the loading time of a respective page. The following K lines each contain two numbers x[i]
and y[i]
(1 ≤ i ≤ K), indicating a link between pages x[i]
and y[i]
.
The last line contains two numbers, A and B (1 ≤ A, B ≤ N), which are the pages between which you need to calculate the transition time.
Output Data
Output the minimum transition time between pages A and B, or -1 if such a transition is not possible.