Gate 21
Time limit2sMemory limit512 MB
Count the straight lines that pass through exactly one integer checkpoint at each gate i, where gate i covers y from l_i to r_i.
Problem
You are participating in a ski race. It is rumored that an autograph of Serj Tankian is the grand prize.
Every racer must pass through gates numbered from 1 to . The -th gate consists of several equivalent checkpoints, which can be considered as points on a plane having coordinates for all integers between and , inclusive. It is required to pass through exactly one checkpoint at every gate in increasing order of gate numbers.
Unfortunately, you are very bad at turning on skis. Thus, you would like to prepare a route for yourself, which is a straight line passing through a single checkpoint at every gate. How many route options do you have?
Input
The first line contains a single integer ().
Each of the next lines contains two integers and ().
Output
Output a single integer, the number of valid straight routes you can take.
Hint
In the example test case, all possible routes are:
- ;
- ;
- ;
- ;
- ;
- .