Michael has discovered a strange planetary system consisting of
The planets happen to orbit in such a way that they align in a straight line in front of the central star at all times. Each planet is located
Additionally, some planets are locked behind force fields that prevent any visitors. These force fields can be deactivated remotely on designated planets. A planet may have multiple force fields, in which case all of them need to be deactivated before visiting it. There are
Michael needs to buy a fuel tank for his spaceship, but wants to minimize the size of the fuel tank in order to cut costs. A fuel tank of capacity
Constraints
All
All force fields are pairwise distinct.
Michael starts on a planet without any force fields and it is possible to disable all the force fields.
Subtask 1 [40%]
Subtask 2 [30%]
Subtask 3 [30%]
No additional constraints.
Input Specification
The first line of input contains integers
The next line of input contains
The next
Output Specification
Output the smallest capacity
Sample Input
4 4 1
5 2 7 9
2 1
3 2
4 3
4 2
Sample Output
3
Comments