Problems
#859
~/algor $ cat problems/OaWd14LVqc3l
A half-price ticket
Medium
2000 ms
256 MB
66%
A country has cities and one-way flights: flight goes from city to city , and its ticket costs soums. You have one discount coupon: used on one flight, it makes that flight's ticket cost soums. What is the smallest amount needed to fly from city to city ? If it is impossible, print .
Input
The first line contains two positive integers: and . Line of the next lines contains three positive integers: , and .
Output
One integer — the smallest cost or .
Note
,
Examples
Input #1
4 5 1 2 8 2 4 6 1 3 3 3 4 12 2 3 1
Output #1
9
Input #2
3 1 2 3 5
Output #2
-1