In the event of technical difficulties with Szkopuł, please contact us via email at szkopul@fri.edu.pl.

If you are familiar with IRC chat, the support team is also reachable on PIRC network (`irc.pirc.pl`

) in `#szkopul`

channel. If you are not, just use email.

Please do not ask us things like "how to solve task XYZ?".

Please remember that the support team has to sleep sometimes or go to work in real life.

We have a lecture hall at our disposal. Lecturers place orders in which they specify at what time their lecture begins and at what time it ends. We want to make maximal use of the hall. We accept some orders and reject others and our aim is to achieve the longest possible time of lectures in the hall. We assume that at the moment when one lecture ends another can begin.

Write a program that:

- reads orders of lecturers from the standard input,
- computes the maximal possible time of lectures,
- writes the result to the standard output.

In the first line of the standard input there is written one positive integer , (), which is the number of orders.

In each of the following lines there are written two integers and , separated by a single space, . Such a pair of integers represents an order for the hall. The lecture is to begin at time and end in time (a lecturer needs the hall in time represented by an open interval).

In the first line of the standard output there should be written the maximal possible time of lectures.

For the input data:

12 1 2 3 5 0 4 6 8 7 13 4 6 9 10 9 12 11 14 15 19 14 16 18 20

the correct result is:

16

*Task author: Wojciech Guzicki.*